netutils/webserver: Fix a few complaints from nutts/tools/nxstyle.

This commit is contained in:
Gregory Nutt 2019-07-04 21:21:26 -06:00
parent 0b352178c1
commit 39ad02f72e
3 changed files with 43 additions and 37 deletions

View File

@ -14,7 +14,6 @@ config NETUTILS_WEBSERVER
if NETUTILS_WEBSERVER
config NETUTILS_HTTPD_SINGLECONNECT
bool "Single Connection"
default n if !DISABLE_PTHREAD
@ -179,5 +178,4 @@ config NETUTILS_HTTPD_DIRLIST
depends on NETUTILS_HTTPD_SENDFILE
default n
endif # NETUTILS_WEBSERVER

View File

@ -331,7 +331,7 @@ static int handle_script(struct httpd_state *pstate)
if (httpd_open(pstate->ht_scriptptr + 1,
&pstate->ht_file) != OK)
{
return ERROR;
return ERROR;
}
status = httpd_send_datachunk(pstate->ht_sockfd,
@ -444,7 +444,10 @@ static int send_headers(struct httpd_state *pstate, int status, int len)
{
const char *mime;
const char *ptr;
char contentlen[HTTPD_MAX_CONTENTLEN] = { 0 };
char contentlen[HTTPD_MAX_CONTENTLEN] =
{
0
};
char header[HTTPD_MAX_HEADERLEN];
int hdrlen;
int i;
@ -456,19 +459,36 @@ static int send_headers(struct httpd_state *pstate, int status, int len)
} a[] =
{
#ifndef CONFIG_NETUTILS_HTTPD_SCRIPT_DISABLE
{ "shtml", "text/html" },
{
"shtml", "text/html"
},
#endif
{ "html", "text/html" },
{ "css", "text/css" },
{ "txt", "text/plain" },
{ "js", "text/javascript" },
{ "png", "image/png" },
{ "gif", "image/gif" },
{ "jpeg", "image/jpeg" },
{ "jpg", "image/jpeg" },
{ "mp3", "audio/mpeg" }
{
"html", "text/html"
},
{
"css", "text/css"
},
{
"txt", "text/plain"
},
{
"js", "text/javascript"
},
{
"png", "image/png"
},
{
"gif", "image/gif"
},
{
"jpeg", "image/jpeg"
},
{
"jpg", "image/jpeg"
},
{ "mp3", "audio/mpeg"
}
};
ptr = strrchr(pstate->ht_filename, ISO_period);
@ -647,7 +667,7 @@ static int httpd_sendfile(struct httpd_state *pstate)
#endif
if (send_headers(pstate, 200, -1) != OK)
{
goto done;
goto done;
}
ret = handle_script(pstate);

View File

@ -54,18 +54,6 @@
#include "httpd.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
@ -85,27 +73,27 @@ int httpd_sendfile_open(const char *name, struct httpd_fs_file *file)
if (-1 == stat(file->path, &st))
{
return ERROR;
return ERROR;
}
#ifndef CONFIG_NETUTILS_HTTPD_DIRLIST
if (S_ISDIR(st.st_mode))
{
errno = EISDIR;
return ERROR;
errno = EISDIR;
return ERROR;
}
if (!S_ISREG(st.st_mode))
{
errno = ENOENT;
return ERROR;
errno = ENOENT;
return ERROR;
}
#endif
if (st.st_size > INT_MAX || st.st_size > SIZE_MAX)
{
errno = EFBIG;
return ERROR;
errno = EFBIG;
return ERROR;
}
file->len = (int) st.st_size;
@ -115,7 +103,7 @@ int httpd_sendfile_open(const char *name, struct httpd_fs_file *file)
#ifndef CONFIG_NETUTILS_HTTPD_DIRLIST
if (file->fd == -1)
{
return ERROR;
return ERROR;
}
#endif