From 5572819bb1dea338b47fb81195bc28b7832ef9d0 Mon Sep 17 00:00:00 2001 From: Alin Jerpelea Date: Fri, 11 Jun 2021 12:06:42 +0200 Subject: [PATCH] netutils: nxstyle fixes fixes for errors reported by nxstyle tool Signed-off-by: Alin Jerpelea --- netutils/ftpc/ftpc_config.h | 3 +- netutils/ftpc/ftpc_help.c | 4 +- netutils/ftpc/ftpc_idle.c | 8 +- netutils/ftpc/ftpc_unlink.c | 4 +- netutils/libcurl4nx/curl4nx_easy_perform.c | 29 ++++--- netutils/libcurl4nx/curl4nx_easy_setopt.c | 2 + netutils/libcurl4nx/curl4nx_private.h | 4 +- netutils/netlib/netlib_delarp.c | 2 +- netutils/netlib/netlib_eaddrconv.c | 8 +- netutils/netlib/netlib_getarp.c | 2 +- netutils/netlib/netlib_getarptab.c | 2 +- netutils/netlib/netlib_getdevs.c | 2 +- netutils/netlib/netlib_getdripv4addr.c | 4 +- netutils/netlib/netlib_getessid.c | 2 +- netutils/netlib/netlib_getifstatus.c | 2 +- netutils/netlib/netlib_getipv4addr.c | 4 +- netutils/netlib/netlib_getipv4netmask.c | 4 +- netutils/netlib/netlib_getipv6addr.c | 2 +- netutils/netlib/netlib_getmacaddr.c | 2 +- netutils/netlib/netlib_getnbtab.c | 2 +- netutils/netlib/netlib_getnodeaddr.c | 2 +- netutils/netlib/netlib_getpanid.c | 20 ++--- netutils/netlib/netlib_getproperties.c | 2 +- netutils/netlib/netlib_ipmsfilter.c | 2 +- netutils/netlib/netlib_ipv4route.c | 18 +++-- netutils/netlib/netlib_ipv4router.c | 6 +- netutils/netlib/netlib_ipv6netmask2prefix.c | 2 +- netutils/netlib/netlib_ipv6route.c | 18 ++--- netutils/netlib/netlib_ipv6router.c | 6 +- netutils/netlib/netlib_listenon.c | 8 +- netutils/netlib/netlib_nodeaddrconv.c | 2 +- netutils/netlib/netlib_parsehttpurl.c | 2 +- netutils/netlib/netlib_saddrconv.c | 8 +- netutils/netlib/netlib_server.c | 13 +-- netutils/netlib/netlib_setarp.c | 2 +- netutils/netlib/netlib_setdripv4addr.c | 3 +- netutils/netlib/netlib_seteaddr.c | 24 +++--- netutils/netlib/netlib_setessid.c | 2 +- netutils/netlib/netlib_setifstatus.c | 2 +- netutils/netlib/netlib_setipv4addr.c | 5 +- netutils/netlib/netlib_setipv4dnsaddr.c | 2 +- netutils/netlib/netlib_setipv4netmask.c | 2 +- netutils/netlib/netlib_setipv6addr.c | 5 +- netutils/netlib/netlib_setipv6netmask.c | 5 +- netutils/netlib/netlib_setmacaddr.c | 2 +- netutils/tftpc/tftpc_get.c | 2 +- netutils/tftpc/tftpc_internal.h | 15 ++-- netutils/tftpc/tftpc_packets.c | 2 +- netutils/tftpc/tftpc_put.c | 2 +- netutils/thttpd/config.h | 89 +++++++++++++-------- netutils/webserver/httpd_mmap.c | 31 +++---- netutils/webserver/httpd_sendfile.c | 5 +- 52 files changed, 228 insertions(+), 173 deletions(-) diff --git a/netutils/ftpc/ftpc_config.h b/netutils/ftpc/ftpc_config.h index 30a6f8e62..ff429f1d7 100644 --- a/netutils/ftpc/ftpc_config.h +++ b/netutils/ftpc/ftpc_config.h @@ -30,6 +30,7 @@ /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ + /* This is a mindless little wrapper around include/nuttx/config.h. Every * file in the ftpc directory includes this file at the very beginning of * of the file (instead of include/nuttx/config.h). The only purpose of @@ -58,7 +59,7 @@ ****************************************************************************/ /**************************************************************************** - * Public Functions + * Public Functions Prototypes ****************************************************************************/ #endif /* __APPS_NETUTILS_FTPC_FTPC_CONFIG_H */ diff --git a/netutils/ftpc/ftpc_help.c b/netutils/ftpc/ftpc_help.c index a91bb01db..fcf28190d 100644 --- a/netutils/ftpc/ftpc_help.c +++ b/netutils/ftpc/ftpc_help.c @@ -77,8 +77,8 @@ int ftpc_help(SESSION handle, FAR const char *arg) ret = ftpc_cmd(session, "HELP"); } - /* Logic is missing here to return the help string to the caller. The caller - * needs to call ftpc_getreply. + /* Logic is missing here to return the help string to the caller. + * The caller needs to call ftpc_getreply. */ return ret; diff --git a/netutils/ftpc/ftpc_idle.c b/netutils/ftpc/ftpc_idle.c index b5f97ffa4..eea2c054b 100644 --- a/netutils/ftpc/ftpc_idle.c +++ b/netutils/ftpc/ftpc_idle.c @@ -75,10 +75,10 @@ int ftpc_idle(SESSION handle, unsigned int idletime) /* Check if the server supports the SITE IDLE command */ if (!FTPC_HAS_IDLE(session)) - { - nwarn("WARNING: Server does not support SITE IDLE\n"); - return ERROR; - } + { + nwarn("WARNING: Server does not support SITE IDLE\n"); + return ERROR; + } /* Did the caller provide an IDLE time? Or is this just a query for the * current IDLE time setting? diff --git a/netutils/ftpc/ftpc_unlink.c b/netutils/ftpc/ftpc_unlink.c index 47c08a8d0..2d99d1962 100644 --- a/netutils/ftpc/ftpc_unlink.c +++ b/netutils/ftpc/ftpc_unlink.c @@ -65,8 +65,8 @@ int ftpc_unlink(SESSION handle, FAR const char *path) FAR struct ftpc_session_s *session = (FAR struct ftpc_session_s *)handle; int ret; - /* A DELE request asks the server to remove a regular file. A typical server - * accepts DELE with: + /* A DELE request asks the server to remove a regular file. + * A typical server accepts DELE with: * * - "250 Requested file action okay, completed" if the file was * successfully removed diff --git a/netutils/libcurl4nx/curl4nx_easy_perform.c b/netutils/libcurl4nx/curl4nx_easy_perform.c index a682b683b..06bb07277 100644 --- a/netutils/libcurl4nx/curl4nx_easy_perform.c +++ b/netutils/libcurl4nx/curl4nx_easy_perform.c @@ -298,7 +298,9 @@ int curl4nx_easy_perform(FAR struct curl4nx_s *handle) rxoff++; } - /* Check for overflow, version code should not fill the tmpbuf */ + /* Check for overflow, + * version code should not fill the tmpbuf + */ if (tmplen == sizeof(tmpbuf)) { @@ -350,7 +352,9 @@ int curl4nx_easy_perform(FAR struct curl4nx_s *handle) rxoff++; } - /* Check for overflow, version code should not fill the tmpbuf */ + /* Check for overflow, + * version code should not fill the tmpbuf + */ if (tmplen == sizeof(tmpbuf)) { @@ -366,7 +370,7 @@ int curl4nx_easy_perform(FAR struct curl4nx_s *handle) if (state == CURL4NX_STATE_STATUSREASON) { - /* Accumulate response code until CRLF */ + /* Accumulate response code until CRLF */ while (rxoff < ret) { @@ -500,15 +504,17 @@ int curl4nx_easy_perform(FAR struct curl4nx_s *handle) handle->max_redirs)) { curl4nx_info( - "Too many redirections\n"); - cret = CURL4NXE_TOO_MANY_REDIRECTS; + "Too many redirections\n"); + cret = + CURL4NXE_TOO_MANY_REDIRECTS; goto close; } cret = - curl4nx_easy_setopt(handle, - CURL4NXOPT_URL, - headerbuf + off); + curl4nx_easy_setopt( + handle, + CURL4NXOPT_URL, + headerbuf + off); if (cret != CURL4NXE_OK) { goto close; @@ -516,9 +522,10 @@ int curl4nx_easy_perform(FAR struct curl4nx_s *handle) redirected = true; redircount += 1; - curl4nx_info("REDIRECTION (%d) -> %s\n", - redircount, - headerbuf + off); + curl4nx_info(" + REDIRECTION (%d) -> %s\n", + redircount, + headerbuf + off); } } } diff --git a/netutils/libcurl4nx/curl4nx_easy_setopt.c b/netutils/libcurl4nx/curl4nx_easy_setopt.c index e94381db3..02fe5d12e 100644 --- a/netutils/libcurl4nx/curl4nx_easy_setopt.c +++ b/netutils/libcurl4nx/curl4nx_easy_setopt.c @@ -120,6 +120,7 @@ int curl4nx_easy_setopt(FAR struct curl4nx_s *handle, int option, cret = CURL4NXE_BAD_FUNCTION_ARGUMENT; break; } + handle->port = (uint16_t)(port & 0xffff); break; } @@ -196,6 +197,7 @@ int curl4nx_easy_setopt(FAR struct curl4nx_s *handle, int option, cret = CURL4NXE_BAD_FUNCTION_ARGUMENT; break; } + handle->max_redirs = redirs; break; } diff --git a/netutils/libcurl4nx/curl4nx_private.h b/netutils/libcurl4nx/curl4nx_private.h index 2b48f22f2..11c311284 100644 --- a/netutils/libcurl4nx/curl4nx_private.h +++ b/netutils/libcurl4nx/curl4nx_private.h @@ -1,5 +1,5 @@ /**************************************************************************** - * apps/netutils/curl4nx/curl4nx_private.h + * apps/netutils/libcurl4nx/curl4nx_private.h * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -96,7 +96,7 @@ while(0) /**************************************************************************** - * Private Types + * Public Types ****************************************************************************/ /**************************************************************************** diff --git a/netutils/netlib/netlib_delarp.c b/netutils/netlib/netlib_delarp.c index f411c95a0..9eb88f88c 100644 --- a/netutils/netlib/netlib_delarp.c +++ b/netutils/netlib/netlib_delarp.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/netlib/netlib_delarp.c + * apps/netutils/netlib/netlib_delarp.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/netutils/netlib/netlib_eaddrconv.c b/netutils/netlib/netlib_eaddrconv.c index 46acbe98b..2f97e05f9 100644 --- a/netutils/netlib/netlib_eaddrconv.c +++ b/netutils/netlib/netlib_eaddrconv.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/netlib/netlib_eaddrconv.c + * apps/netutils/netlib/netlib_eaddrconv.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -61,9 +61,9 @@ bool netlib_eaddrconv(FAR const char *hwstr, FAR uint8_t *hw) { ch = *hwstr++; if (++j > 3) - { - return false; - } + { + return false; + } if (ch == ':' || ch == '\0') { diff --git a/netutils/netlib/netlib_getarp.c b/netutils/netlib/netlib_getarp.c index 7f412fc0e..80cdb424e 100644 --- a/netutils/netlib/netlib_getarp.c +++ b/netutils/netlib/netlib_getarp.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/netlib/netlib_getarp.c + * apps/netutils/netlib/netlib_getarp.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/netutils/netlib/netlib_getarptab.c b/netutils/netlib/netlib_getarptab.c index fc3a7b66b..ad2b0c9d1 100644 --- a/netutils/netlib/netlib_getarptab.c +++ b/netutils/netlib/netlib_getarptab.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/netlib/netlib_getarptab.c + * apps/netutils/netlib/netlib_getarptab.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/netutils/netlib/netlib_getdevs.c b/netutils/netlib/netlib_getdevs.c index 2d8702559..fba96e726 100644 --- a/netutils/netlib/netlib_getdevs.c +++ b/netutils/netlib/netlib_getdevs.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/netlib/netlib_getdevs.c + * apps/netutils/netlib/netlib_getdevs.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/netutils/netlib/netlib_getdripv4addr.c b/netutils/netlib/netlib_getdripv4addr.c index 99eb14f58..1fc1b56a9 100644 --- a/netutils/netlib/netlib_getdripv4addr.c +++ b/netutils/netlib/netlib_getdripv4addr.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/netlib/netlib_getdripv4addr.c + * apps/netutils/netlib/netlib_getdripv4addr.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -76,7 +76,7 @@ int netlib_get_dripv4addr(FAR const char *ifname, FAR struct in_addr *addr) { FAR struct sockaddr_in *req_addr; - req_addr = (FAR struct sockaddr_in*)&req.ifr_addr; + req_addr = (FAR struct sockaddr_in *)&req.ifr_addr; memcpy(addr, &req_addr->sin_addr, sizeof(struct in_addr)); } diff --git a/netutils/netlib/netlib_getessid.c b/netutils/netlib/netlib_getessid.c index 0db085178..70cc2a35c 100644 --- a/netutils/netlib/netlib_getessid.c +++ b/netutils/netlib/netlib_getessid.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/netlib/netlib_getessid.c + * apps/netutils/netlib/netlib_getessid.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/netutils/netlib/netlib_getifstatus.c b/netutils/netlib/netlib_getifstatus.c index f8d174ff8..f3f0ab7a1 100644 --- a/netutils/netlib/netlib_getifstatus.c +++ b/netutils/netlib/netlib_getifstatus.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/netlib/netlib_getifstatus.c + * apps/netutils/netlib/netlib_getifstatus.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/netutils/netlib/netlib_getipv4addr.c b/netutils/netlib/netlib_getipv4addr.c index a7985174b..1e1cc718f 100644 --- a/netutils/netlib/netlib_getipv4addr.c +++ b/netutils/netlib/netlib_getipv4addr.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/netlib/netlib_getipv4addr.c + * apps/netutils/netlib/netlib_getipv4addr.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -76,7 +76,7 @@ int netlib_get_ipv4addr(FAR const char *ifname, FAR struct in_addr *addr) { FAR struct sockaddr_in *req_addr; - req_addr = (FAR struct sockaddr_in*)&req.ifr_addr; + req_addr = (FAR struct sockaddr_in *)&req.ifr_addr; memcpy(addr, &req_addr->sin_addr, sizeof(struct in_addr)); } diff --git a/netutils/netlib/netlib_getipv4netmask.c b/netutils/netlib/netlib_getipv4netmask.c index 823d1aebc..0e11658a8 100644 --- a/netutils/netlib/netlib_getipv4netmask.c +++ b/netutils/netlib/netlib_getipv4netmask.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/netlib/netlib_getipv4netmask.c + * apps/netutils/netlib/netlib_getipv4netmask.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -76,7 +76,7 @@ int netlib_get_ipv4netmask(FAR const char *ifname, FAR struct in_addr *addr) { FAR struct sockaddr_in *req_addr; - req_addr = (FAR struct sockaddr_in*)&req.ifr_addr; + req_addr = (FAR struct sockaddr_in *)&req.ifr_addr; memcpy(addr, &req_addr->sin_addr, sizeof(struct in_addr)); } diff --git a/netutils/netlib/netlib_getipv6addr.c b/netutils/netlib/netlib_getipv6addr.c index 39516a32a..6bbfffbe7 100644 --- a/netutils/netlib/netlib_getipv6addr.c +++ b/netutils/netlib/netlib_getipv6addr.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/netlib/netlib_getipv6addr.c + * apps/netutils/netlib/netlib_getipv6addr.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/netutils/netlib/netlib_getmacaddr.c b/netutils/netlib/netlib_getmacaddr.c index 54c9ddf1a..96eebe18b 100644 --- a/netutils/netlib/netlib_getmacaddr.c +++ b/netutils/netlib/netlib_getmacaddr.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/netlib/netlib_getmacaddr.c + * apps/netutils/netlib/netlib_getmacaddr.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/netutils/netlib/netlib_getnbtab.c b/netutils/netlib/netlib_getnbtab.c index ffe05e993..c5c249d95 100644 --- a/netutils/netlib/netlib_getnbtab.c +++ b/netutils/netlib/netlib_getnbtab.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/netlib/netlib_getntab.c + * apps/netutils/netlib/netlib_getnbtab.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/netutils/netlib/netlib_getnodeaddr.c b/netutils/netlib/netlib_getnodeaddr.c index af381651d..106f48fb7 100644 --- a/netutils/netlib/netlib_getnodeaddr.c +++ b/netutils/netlib/netlib_getnodeaddr.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/netlib/netlib_getnodnodeaddr.c + * apps/netutils/netlib/netlib_getnodeaddr.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/netutils/netlib/netlib_getpanid.c b/netutils/netlib/netlib_getpanid.c index ec61c28ec..c78eb1047 100644 --- a/netutils/netlib/netlib_getpanid.c +++ b/netutils/netlib/netlib_getpanid.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/netlib/netlib_getpanid.c + * apps/netutils/netlib/netlib_getpanid.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -72,17 +72,17 @@ int netlib_getpanid(FAR const char *ifname, FAR uint8_t *panid) { /* Perform the IOCTL */ - strncpy(arg.ifr_name, ifname, IFNAMSIZ); - arg.u.getreq.attr = IEEE802154_ATTR_MAC_PANID; + strncpy(arg.ifr_name, ifname, IFNAMSIZ); + arg.u.getreq.attr = IEEE802154_ATTR_MAC_PANID; - ret = ioctl(sockfd, MAC802154IOC_MLME_GET_REQUEST, + ret = ioctl(sockfd, MAC802154IOC_MLME_GET_REQUEST, (unsigned long)((uintptr_t)&arg)); - if (ret < 0) - { - ret = -errno; - fprintf(stderr, "MAC802154IOC_MLME_GET_REQUEST failed: %d\n", - ret); - } + if (ret < 0) + { + ret = -errno; + fprintf(stderr, "MAC802154IOC_MLME_GET_REQUEST failed: %d\n", + ret); + } close(sockfd); IEEE802154_PANIDCOPY(panid, arg.u.getreq.attrval.mac.panid); diff --git a/netutils/netlib/netlib_getproperties.c b/netutils/netlib/netlib_getproperties.c index e34c02683..6065d2a14 100644 --- a/netutils/netlib/netlib_getproperties.c +++ b/netutils/netlib/netlib_getproperties.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/netlib/netlib_getproperties.c + * apps/netutils/netlib/netlib_getproperties.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/netutils/netlib/netlib_ipmsfilter.c b/netutils/netlib/netlib_ipmsfilter.c index c2fb1a53c..b2c60a14c 100644 --- a/netutils/netlib/netlib_ipmsfilter.c +++ b/netutils/netlib/netlib_ipmsfilter.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/netlib/netlib_setipmsfilter.c + * apps/netutils/netlib/netlib_ipmsfilter.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/netutils/netlib/netlib_ipv4route.c b/netutils/netlib/netlib_ipv4route.c index 6c21c5b00..f5343801c 100644 --- a/netutils/netlib/netlib_ipv4route.c +++ b/netutils/netlib/netlib_ipv4route.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/netlib/netlib_ipv4route.c + * apps/netutils/netlib/netlib_ipv4route.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -71,14 +71,16 @@ static void set_nul_terminator(FAR char *str) { - /* The first non-decimal character that is not '.' terminates the address */ + /* The first non-decimal character that is not '.' terminates the + * address + */ - while ((*str >= '0' && *str <= '9') || *str == '.') - { - str++; - } + while ((*str >= '0' && *str <= '9') || *str == '.') + { + str++; + } - *str = '\0'; + *str = '\0'; } /**************************************************************************** @@ -173,7 +175,7 @@ ssize_t netlib_read_ipv4route(FILE *stream, { return sizeof(struct netlib_ipv4_route_s); } - } + } } return ret < 0 ? ret : -EINVAL; diff --git a/netutils/netlib/netlib_ipv4router.c b/netutils/netlib/netlib_ipv4router.c index dab0e285a..73f672daf 100644 --- a/netutils/netlib/netlib_ipv4router.c +++ b/netutils/netlib/netlib_ipv4router.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/netlib/netlib_ipv4router.c + * apps/netutils/netlib/netlib_ipv4router.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -81,7 +81,9 @@ int netlib_ipv4router(FAR const struct in_addr *destipaddr, hdest = ntohl(destipaddr->s_addr); - /* Find the routing table entry that provides the router for this sub-net. */ + /* Find the routing table entry that provides the router for this + * sub-net. + */ for (; ; ) { diff --git a/netutils/netlib/netlib_ipv6netmask2prefix.c b/netutils/netlib/netlib_ipv6netmask2prefix.c index 5f1f9c903..c945dca41 100644 --- a/netutils/netlib/netlib_ipv6netmask2prefix.c +++ b/netutils/netlib/netlib_ipv6netmask2prefix.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/netlib/netlib_ipv6netmask2prefix.c + * apps/netutils/netlib/netlib_ipv6netmask2prefix.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/netutils/netlib/netlib_ipv6route.c b/netutils/netlib/netlib_ipv6route.c index 9900ade9a..59858b661 100644 --- a/netutils/netlib/netlib_ipv6route.c +++ b/netutils/netlib/netlib_ipv6route.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/netlib/netlib_ipv6route.c + * apps/netutils/netlib/netlib_ipv6route.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -70,17 +70,17 @@ static void set_nul_terminator(FAR char *str) { - /* The first non-hex character that is not ':' terminates the address */ + /* The first non-hex character that is not ':' terminates the address */ - while ((*str >= '0' && *str <= '9') || - (*str >= 'a' && *str <= 'f') || - (*str >= 'A' && *str <= 'F') || - *str == ':') - { + while ((*str >= '0' && *str <= '9') || + (*str >= 'a' && *str <= 'f') || + (*str >= 'A' && *str <= 'F') || + *str == ':') + { str++; - } + } - *str = '\0'; + *str = '\0'; } /**************************************************************************** diff --git a/netutils/netlib/netlib_ipv6router.c b/netutils/netlib/netlib_ipv6router.c index d4a76f390..bb7ff3dbe 100644 --- a/netutils/netlib/netlib_ipv6router.c +++ b/netutils/netlib/netlib_ipv6router.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/netlib/netlib_ipv6router.c + * apps/netutils/netlib/netlib_ipv6router.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -88,7 +88,9 @@ int netlib_ipv6router(FAR const struct in6_addr *destipaddr, hdest[6] = ntohs(destipaddr->s6_addr16[6]); hdest[7] = ntohs(destipaddr->s6_addr16[7]); - /* Find the routing table entry that provides the router for this sub-net. */ + /* Find the routing table entry that provides the router for this + * sub-net. + */ for (; ; ) { diff --git a/netutils/netlib/netlib_listenon.c b/netutils/netlib/netlib_listenon.c index 0a5c4a2ba..134825411 100644 --- a/netutils/netlib/netlib_listenon.c +++ b/netutils/netlib/netlib_listenon.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/netlib/netlib_listenon.c + * apps/netutils/netlib/netlib_listenon.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -77,7 +77,8 @@ int netlib_listenon(uint16_t portno) /* Set socket to reuse address */ optval = 1; - if (setsockopt(listensd, SOL_SOCKET, SO_REUSEADDR, (void*)&optval, sizeof(int)) < 0) + if (setsockopt(listensd, SOL_SOCKET, + SO_REUSEADDR, (void *)&optval, sizeof(int)) < 0) { nwarn("WARNING: setsockopt SO_REUSEADDR failure: %d\n", errno); } @@ -88,7 +89,8 @@ int netlib_listenon(uint16_t portno) myaddr.sin_port = portno; myaddr.sin_addr.s_addr = INADDR_ANY; - if (bind(listensd, (struct sockaddr*)&myaddr, sizeof(struct sockaddr_in)) < 0) + if (bind(listensd, (struct sockaddr *)&myaddr, + sizeof(struct sockaddr_in)) < 0) { nerr("ERROR: bind failure: %d\n", errno); goto errout_with_socket; diff --git a/netutils/netlib/netlib_nodeaddrconv.c b/netutils/netlib/netlib_nodeaddrconv.c index 1ca415e18..76816725f 100644 --- a/netutils/netlib/netlib_nodeaddrconv.c +++ b/netutils/netlib/netlib_nodeaddrconv.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/netlib/netlib_nodeaddrconv.c + * apps/netutils/netlib/netlib_nodeaddrconv.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/netutils/netlib/netlib_parsehttpurl.c b/netutils/netlib/netlib_parsehttpurl.c index ed7ee07ec..21a78683a 100644 --- a/netutils/netlib/netlib_parsehttpurl.c +++ b/netutils/netlib/netlib_parsehttpurl.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/netlib/netlib_parsehttpurl.c + * apps/netutils/netlib/netlib_parsehttpurl.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/netutils/netlib/netlib_saddrconv.c b/netutils/netlib/netlib_saddrconv.c index 1a0609770..069ba11eb 100644 --- a/netutils/netlib/netlib_saddrconv.c +++ b/netutils/netlib/netlib_saddrconv.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/netlib/netlib_saddrconv.c + * apps/netutils/netlib/netlib_saddrconv.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -61,9 +61,9 @@ bool netlib_saddrconv(FAR const char *hwstr, FAR uint8_t *hw) { ch = *hwstr++; if (++j > 3) - { - return false; - } + { + return false; + } if (ch == ':' || ch == '\0') { diff --git a/netutils/netlib/netlib_server.c b/netutils/netlib/netlib_server.c index 57dadd305..d8a57b7b2 100644 --- a/netutils/netlib/netlib_server.c +++ b/netutils/netlib/netlib_server.c @@ -63,7 +63,8 @@ * ****************************************************************************/ -void netlib_server(uint16_t portno, pthread_startroutine_t handler, int stacksize) +void netlib_server(uint16_t portno, + pthread_startroutine_t handler, int stacksize) { struct sockaddr_in myaddr; #ifdef CONFIG_NET_SOLINGER @@ -86,12 +87,12 @@ void netlib_server(uint16_t portno, pthread_startroutine_t handler, int stacksiz /* Begin serving connections */ - for (;;) + for (; ; ) { /* Accept the next connectin */ addrlen = sizeof(struct sockaddr_in); - acceptsd = accept(listensd, (struct sockaddr*)&myaddr, &addrlen); + acceptsd = accept(listensd, (struct sockaddr *)&myaddr, &addrlen); if (acceptsd < 0) { nerr("ERROR: accept failure: %d\n", errno); @@ -108,7 +109,8 @@ void netlib_server(uint16_t portno, pthread_startroutine_t handler, int stacksiz ling.l_onoff = 1; ling.l_linger = 30; /* timeout is seconds */ - ret = setsockopt(acceptsd, SOL_SOCKET, SO_LINGER, &ling, sizeof(struct linger)); + ret = setsockopt(acceptsd, SOL_SOCKET, + SO_LINGER, &ling, sizeof(struct linger)); if (ret < 0) { close(acceptsd); @@ -124,7 +126,8 @@ void netlib_server(uint16_t portno, pthread_startroutine_t handler, int stacksiz pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, stacksize); - ret = pthread_create(&child, &attr, handler, (pthread_addr_t)((uintptr_t)acceptsd)); + ret = pthread_create(&child, &attr, + handler, (pthread_addr_t)((uintptr_t)acceptsd)); if (ret != 0) { /* Close the connection */ diff --git a/netutils/netlib/netlib_setarp.c b/netutils/netlib/netlib_setarp.c index 752e9ba99..40635c953 100644 --- a/netutils/netlib/netlib_setarp.c +++ b/netutils/netlib/netlib_setarp.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/netlib/netlib_setarp.c + * apps/netutils/netlib/netlib_setarp.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/netutils/netlib/netlib_setdripv4addr.c b/netutils/netlib/netlib_setdripv4addr.c index 61643b863..e08e3aa81 100644 --- a/netutils/netlib/netlib_setdripv4addr.c +++ b/netutils/netlib/netlib_setdripv4addr.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/netlib/netlib_setdripv4addr.c + * apps/netutils/netlib/netlib_setdripv4addr.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -105,6 +105,7 @@ int netlib_set_dripv4addr(FAR const char *ifname, if (OK == ret) { /* Delete the default route first */ + /* This call fails if no default route exists, but it's OK */ delroute(sockfd, diff --git a/netutils/netlib/netlib_seteaddr.c b/netutils/netlib/netlib_seteaddr.c index 3304cde24..1bd211cfd 100644 --- a/netutils/netlib/netlib_seteaddr.c +++ b/netutils/netlib/netlib_seteaddr.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/netlib/netlib_seteaddr.c + * apps/netutils/netlib/netlib_seteaddr.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -72,20 +72,20 @@ int netlib_seteaddr(FAR const char *ifname, FAR const uint8_t *eaddr) { /* Perform the IOCTL */ - strncpy(arg.ifr_name, ifname, IFNAMSIZ); - arg.u.setreq.attr = IEEE802154_ATTR_MAC_EADDR; - IEEE802154_EADDRCOPY(arg.u.setreq.attrval.mac.eaddr, eaddr); + strncpy(arg.ifr_name, ifname, IFNAMSIZ); + arg.u.setreq.attr = IEEE802154_ATTR_MAC_EADDR; + IEEE802154_EADDRCOPY(arg.u.setreq.attrval.mac.eaddr, eaddr); - ret = ioctl(sockfd, MAC802154IOC_MLME_SET_REQUEST, + ret = ioctl(sockfd, MAC802154IOC_MLME_SET_REQUEST, (unsigned long)((uintptr_t)&arg)); - if (ret < 0) - { - ret = -errno; - fprintf(stderr, "MAC802154IOC_MLME_SET_REQUEST failed: %d\n", - ret); - } + if (ret < 0) + { + ret = -errno; + fprintf(stderr, "MAC802154IOC_MLME_SET_REQUEST failed: %d\n", + ret); + } - close(sockfd); + close(sockfd); } } diff --git a/netutils/netlib/netlib_setessid.c b/netutils/netlib/netlib_setessid.c index 74e0092e5..fb84937b3 100644 --- a/netutils/netlib/netlib_setessid.c +++ b/netutils/netlib/netlib_setessid.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/netlib/netlib_setessid.c + * apps/netutils/netlib/netlib_setessid.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/netutils/netlib/netlib_setifstatus.c b/netutils/netlib/netlib_setifstatus.c index eb53f5600..84f0da821 100644 --- a/netutils/netlib/netlib_setifstatus.c +++ b/netutils/netlib/netlib_setifstatus.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/netlib/netlib_setifstatus.c + * apps/netutils/netlib/netlib_setifstatus.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/netutils/netlib/netlib_setipv4addr.c b/netutils/netlib/netlib_setipv4addr.c index fc5a7b549..a1a030ff1 100644 --- a/netutils/netlib/netlib_setipv4addr.c +++ b/netutils/netlib/netlib_setipv4addr.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/netlib/netlib_setipv4addr.c + * apps/netutils/netlib/netlib_setipv4addr.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -56,7 +56,8 @@ * ****************************************************************************/ -int netlib_set_ipv4addr(FAR const char *ifname, FAR const struct in_addr *addr) +int netlib_set_ipv4addr(FAR const char *ifname, + FAR const struct in_addr *addr) { int ret = ERROR; diff --git a/netutils/netlib/netlib_setipv4dnsaddr.c b/netutils/netlib/netlib_setipv4dnsaddr.c index f18a26407..4d4e82404 100644 --- a/netutils/netlib/netlib_setipv4dnsaddr.c +++ b/netutils/netlib/netlib_setipv4dnsaddr.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/netlib/netlib_setipv4dnsaddr.c + * apps/netutils/netlib/netlib_setipv4dnsaddr.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/netutils/netlib/netlib_setipv4netmask.c b/netutils/netlib/netlib_setipv4netmask.c index d27290fb7..85c8dba72 100644 --- a/netutils/netlib/netlib_setipv4netmask.c +++ b/netutils/netlib/netlib_setipv4netmask.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/netlib/netlib_setipv4netmask.c + * apps/netutils/netlib/netlib_setipv4netmask.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/netutils/netlib/netlib_setipv6addr.c b/netutils/netlib/netlib_setipv6addr.c index ae8f9749f..de193b15f 100644 --- a/netutils/netlib/netlib_setipv6addr.c +++ b/netutils/netlib/netlib_setipv6addr.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/netlib/netlib_setipv6addr.c + * apps/netutils/netlib/netlib_setipv6addr.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -80,7 +80,8 @@ int netlib_set_ipv6addr(FAR const char *ifname, inaddr->sin6_port = 0; memcpy(&inaddr->sin6_addr, addr, sizeof(struct in6_addr)); - ret = ioctl(sockfd, SIOCSLIFADDR, ((unsigned long)(uintptr_t)&req)); + ret = ioctl(sockfd, SIOCSLIFADDR, + ((unsigned long)(uintptr_t)&req)); close(sockfd); } } diff --git a/netutils/netlib/netlib_setipv6netmask.c b/netutils/netlib/netlib_setipv6netmask.c index c11772ddd..e8707d8b5 100644 --- a/netutils/netlib/netlib_setipv6netmask.c +++ b/netutils/netlib/netlib_setipv6netmask.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/netlib/netlib_setipv6netmask.c + * apps/netutils/netlib/netlib_setipv6netmask.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -79,7 +79,8 @@ int netlib_set_ipv6netmask(FAR const char *ifname, inaddr->sin6_port = 0; memcpy(&inaddr->sin6_addr, addr, sizeof(struct in6_addr)); - ret = ioctl(sockfd, SIOCSLIFNETMASK, (unsigned long)((uintptr_t)&req)); + ret = ioctl(sockfd, SIOCSLIFNETMASK, + (unsigned long)((uintptr_t)&req)); close(sockfd); } } diff --git a/netutils/netlib/netlib_setmacaddr.c b/netutils/netlib/netlib_setmacaddr.c index f907d5fa8..cf63a88ac 100644 --- a/netutils/netlib/netlib_setmacaddr.c +++ b/netutils/netlib/netlib_setmacaddr.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/netlib/netlib_setmacaddr.c + * apps/netutils/netlib/netlib_setmacaddr.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/netutils/tftpc/tftpc_get.c b/netutils/tftpc/tftpc_get.c index 51f4d80c0..0b6310036 100644 --- a/netutils/tftpc/tftpc_get.c +++ b/netutils/tftpc/tftpc_get.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/tftp/tftpc_get.c + * apps/netutils/tftpc/tftpc_get.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/netutils/tftpc/tftpc_internal.h b/netutils/tftpc/tftpc_internal.h index 83067785c..480d7fc2f 100644 --- a/netutils/tftpc/tftpc_internal.h +++ b/netutils/tftpc/tftpc_internal.h @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/tftoc/tftpc_internal.h + * apps/netutils/tftpc/tftpc_internal.h * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -42,6 +42,7 @@ ****************************************************************************/ /* Verify TFTP configuration settings ***************************************/ + /* The settings beginning with CONFIG_NETUTILS_TFTP_* can all be set in the * NuttX configuration file. If they are are defined in the configuration * then default values are assigned here. @@ -157,15 +158,19 @@ /* Defined in tftp_packet.c *************************************************/ extern int tftp_sockinit(struct sockaddr_in *server, in_addr_t addr); -extern int tftp_mkreqpacket(uint8_t *buffer, int opcode, const char *path, bool binary); +extern int tftp_mkreqpacket(uint8_t *buffer, int opcode, + const char *path, bool binary); extern int tftp_mkackpacket(uint8_t *buffer, uint16_t blockno); -extern int tftp_mkerrpacket(uint8_t *buffer, uint16_t errorcode, const char *errormsg); +extern int tftp_mkerrpacket(uint8_t *buffer, uint16_t errorcode, + const char *errormsg); #ifdef CONFIG_DEBUG_NET_WARN extern int tftp_parseerrpacket(const uint8_t *packet); #endif -extern ssize_t tftp_recvfrom(int sd, void *buf, size_t len, struct sockaddr_in *from); -extern ssize_t tftp_sendto(int sd, const void *buf, size_t len, struct sockaddr_in *to); +extern ssize_t tftp_recvfrom(int sd, void *buf, + size_t len, struct sockaddr_in *from); +extern ssize_t tftp_sendto(int sd, const void *buf, + size_t len, struct sockaddr_in *to); #ifdef CONFIG_NETUTILS_TFTP_DUMPBUFFERS # define tftp_dumpbuffer(msg, buffer, nbytes) ninfodumpbuffer(msg, buffer, nbytes) diff --git a/netutils/tftpc/tftpc_packets.c b/netutils/tftpc/tftpc_packets.c index 6b4ecdd92..dae95f81a 100644 --- a/netutils/tftpc/tftpc_packets.c +++ b/netutils/tftpc/tftpc_packets.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/tftp/tftpc_packets.c + * apps/netutils/tftpc/tftpc_packets.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/netutils/tftpc/tftpc_put.c b/netutils/tftpc/tftpc_put.c index 5d4366cd0..216979564 100644 --- a/netutils/tftpc/tftpc_put.c +++ b/netutils/tftpc/tftpc_put.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/tftp/tftpc_put.c + * apps/netutils/tftpc/tftpc_put.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/netutils/thttpd/config.h b/netutils/thttpd/config.h index 1a85f75b1..d389df8b1 100644 --- a/netutils/thttpd/config.h +++ b/netutils/thttpd/config.h @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/thttpd/config.h + * apps/netutils/thttpd/config.h * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -22,7 +22,7 @@ #define __NETUTILS_THTTPD_CONFIG_H /**************************************************************************** - * Included files + * Included Files ****************************************************************************/ #include @@ -88,15 +88,17 @@ # define CONFIG_THTTPD_CGI_PATH "/mnt/www/cgi-bin" # endif -/* Only CGI programs whose fully expanded paths match this pattern will be executed. In fact, - * if this value is not defined then no CGI logic will be built. +/* Only CGI programs whose fully expanded paths match this pattern will be + * executed. In fact, if this value is not defined then no CGI logic will + * be built. */ # ifndef CONFIG_THTTPD_CGI_PATTERN # define CONFIG_THTTPD_CGI_PATTERN "/mnt/www/cgi-bin/*" # endif -/* These provide the priority and stack size of the CGI child tasks */ +/* These provide the priority and stack size of the CGI child tasks + */ # ifndef CONFIG_THTTPD_CGI_PRIORITY # define CONFIG_THTTPD_CGI_PRIORITY 50 @@ -106,25 +108,29 @@ # define CONFIG_THTTPD_CGI_STACKSIZE 2048 # endif -/* Byte output limit for CGI tasks */ +/* Byte output limit for CGI tasks + */ # ifndef CONFIG_THTTPD_CGI_BYTECOUNT # define CONFIG_THTTPD_CGI_BYTECOUNT 200000 # endif -/* How many seconds to allow CGI programs to run before killing them. */ +/* How many seconds to allow CGI programs to run before killing them. + */ # ifndef CONFIG_THTTPD_CGI_TIMELIMIT # define CONFIG_THTTPD_CGI_TIMELIMIT 0 /* No time limit */ # endif -/* The default character set name to use with text MIME types. */ +/* The default character set name to use with text MIME types. + */ # ifndef CONFIG_THTTPD_CHARSET # define CONFIG_THTTPD_CHARSET "iso-8859-1" # endif -/* Initial buffer size, buffer reallocation increment, maximum buffer size */ +/* Initial buffer size, buffer reallocation increment, maximum buffer size + */ # ifndef CONFIG_THTTPD_IOBUFFERSIZE # define CONFIG_THTTPD_IOBUFFERSIZE 256 @@ -154,78 +160,93 @@ # error "Can't use uint16_t for buffer size" # endif -/* A list of index filenames to check. The files are searched for in this order. */ +/* A list of index filenames to check. + * The files are searched for in this order. + */ # ifndef CONFIG_THTTPD_INDEX_NAMES # define CONFIG_THTTPD_INDEX_NAMES "index.html", "index.htm", "index.cgi" # endif -/* CONFIG_AUTH_FILE - The file to use for authentication. If this is defined then - * thttpd checks for this file in the local directory before every fetch. If the - * file exists then authentication is done, otherwise the fetch proceeds as usual. - * If you leave this undefined then thttpd will not implement authentication at - * all and will not check for auth files, which saves a bit of CPU time. - * A typical value is ".htpasswd" +/* CONFIG_AUTH_FILE - The file to use for authentication. If this is defined + * then thttpd checks for this file in the local directory before every + * fetch. If the file exists then authentication is done, otherwise the + * fetch proceeds as usual. + * If you leave this undefined then thttpd will not implement + * authentication at all and will not check for auth files, which saves a + * bit of CPU time. A typical value is ".htpasswd" */ -/* The listen() backlog queue length. */ +/* The listen() backlog queue length. + */ # ifndef CONFIG_THTTPD_LISTEN_BACKLOG # define CONFIG_THTTPD_LISTEN_BACKLOG 8 # endif -/* How many milliseconds to leave a connection open while doing a lingering close */ +/* How many milliseconds to leave a connection open while doing a lingering + * close + */ # ifndef CONFIG_THTTPD_LINGER_MSEC # define CONFIG_THTTPD_LINGER_MSEC 500 # endif -/* How often to run the occasional cleanup job.*/ +/* How often to run the occasional cleanup job. + */ # ifndef CONFIG_THTTPD_OCCASIONAL_MSEC # define CONFIG_THTTPD_OCCASIONAL_MSEC 120 /* Two minutes */ # endif -/* How many seconds to allow for reading the initial request on a new connection. */ +/* How many seconds to allow for reading the initial request on a new + * connection. + */ # ifndef CONFIG_THTTPD_IDLE_READ_LIMIT_SEC # define CONFIG_THTTPD_IDLE_READ_LIMIT_SEC 300 # endif -/* How many seconds before an idle connection gets closed. */ +/* How many seconds before an idle connection gets closed. + */ # ifndef CONFIG_THTTPD_IDLE_SEND_LIMIT_SEC # define CONFIG_THTTPD_IDLE_SEND_LIMIT_SEC 300 # endif -/* Memory debug instrumentation depends on other debug options */ +/* Memory debug instrumentation depends on other debug options + */ # if (!defined(CONFIG_DEBUG_FEATURES) || !defined(CONFIG_DEBUG_NET)) && defined(CONFIG_THTTPD_MEMDEBUG) # undef CONFIG_THTTPD_MEMDEBUG # endif -/* Tilde mapping. Many URLs use ~username to indicate a user's home directory. thttpd - * provides two options for mapping this construct to an actual filename. +/* Tilde mapping. + * Many URLs use ~username to indicate a user's home directory. + * thttpd provides two options for mapping this construct to an actual + * filename. * - * 1) Map ~username to /username. This is the recommended choice. Each user - * gets a subdirectory in the main web tree, and the tilde construct points there. + * 1) Map ~username to /username. This is the recommended choice. + * Each user gets a subdirectory in the main web tree, and the tilde + * construct points there. * The prefix could be something like "users", or it could be empty. - * 2) Map ~username to /. The postfix would be the name of - * a subdirectory off of the user's actual home dir, something like "public_html". + * 2) Map ~username to /. The postfix would be + * the name of a subdirectory off of the user's actual home dir, something + * like "public_html". * - * You can also leave both options undefined, and thttpd will not do anything special - * about tildes. Enabling both options is an error. + * You can also leave both options undefined, and thttpd will not do anything + * special about tildes. Enabling both options is an error. * - * Typical values, if they're defined, are "users" for CONFIG_THTTPD_TILDE_MAP1 and "public_html" - * for CONFIG_THTTPD_TILDE_MAP2. + * Typical values, if they're defined, are "users" for + * CONFIG_THTTPD_TILDE_MAP1 and "public_html" for CONFIG_THTTPD_TILDE_MAP2. */ # if defined(CONFIG_THTTPD_TILDE_MAP1) && defined(CONFIG_THTTPD_TILDE_MAP2) # error "Both CONFIG_THTTPD_TILDE_MAP1 and CONFIG_THTTPD_TILDE_MAP2 are defined" # endif -/* If CONFIG_THTTPD_URLPATTERN is defined, then it will be used to match and verify - * referrers. +/* If CONFIG_THTTPD_URLPATTERN is defined, then it will be used to match and + * verify referrers. */ #else /* Dependencies not provided */ diff --git a/netutils/webserver/httpd_mmap.c b/netutils/webserver/httpd_mmap.c index ab0cd9c2f..10686c40c 100644 --- a/netutils/webserver/httpd_mmap.c +++ b/netutils/webserver/httpd_mmap.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/webserver/httpd_mmap.c + * apps/netutils/webserver/httpd_mmap.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -19,7 +19,7 @@ ****************************************************************************/ /**************************************************************************** - * Included Header Files + * Included Files ****************************************************************************/ #include @@ -71,30 +71,32 @@ int httpd_mmap_open(const char *name, struct httpd_fs_file *file) if (-1 == stat(path, &st)) { - return ERROR; + return ERROR; } 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; } if (st.st_size > INT_MAX) { - errno = EFBIG; - return ERROR; + errno = EFBIG; + return ERROR; } file->len = (int) st.st_size; - /* SUS3: "If len is zero, mmap() shall fail and no mapping shall be established." */ + /* SUS3: "If len is zero, mmap() shall fail and no mapping shall + * be established." + */ if (st.st_size == 0) { @@ -104,14 +106,15 @@ int httpd_mmap_open(const char *name, struct httpd_fs_file *file) file->fd = open(path, O_RDONLY); if (file->fd == -1) { - return ERROR; + return ERROR; } - file->data = mmap(NULL, st.st_size, PROT_READ, MAP_SHARED | MAP_FILE, file->fd, 0); + file->data = mmap(NULL, st.st_size, PROT_READ, + MAP_SHARED | MAP_FILE, file->fd, 0); if (file->data == MAP_FAILED) { - close(file->fd); - return ERROR; + close(file->fd); + return ERROR; } return OK; diff --git a/netutils/webserver/httpd_sendfile.c b/netutils/webserver/httpd_sendfile.c index 7c33861b3..a54bdf262 100644 --- a/netutils/webserver/httpd_sendfile.c +++ b/netutils/webserver/httpd_sendfile.c @@ -1,5 +1,5 @@ /**************************************************************************** - * netutils/webserver/httpd_mmap.c + * apps/netutils/webserver/httpd_sendfile.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -19,7 +19,7 @@ ****************************************************************************/ /**************************************************************************** - * Included Header Files + * Included Files ****************************************************************************/ #include @@ -105,6 +105,7 @@ int httpd_sendfile_close(struct httpd_fs_file *file) return OK; } #endif + if (-1 == close(file->fd)) { return ERROR;