From 319203d5d8a7a6004292f48703c2946dd4417a95 Mon Sep 17 00:00:00 2001 From: Petro Karashchenko Date: Mon, 4 Apr 2022 12:36:53 +0200 Subject: [PATCH] apps: unify FAR attribute usage across apps Signed-off-by: Petro Karashchenko --- examples/mqttc/mqttc_pub.c | 27 ++++++++++++++------------- netutils/ftpd/ftpd.c | 2 +- netutils/ftpd/ftpd.h | 14 +++++++------- netutils/pppd/ppp.c | 23 ++++++++++++----------- system/uniqueid/uniqueid_main.c | 29 +++++++++++++++-------------- 5 files changed, 49 insertions(+), 46 deletions(-) diff --git a/examples/mqttc/mqttc_pub.c b/examples/mqttc/mqttc_pub.c index 6394dbf3e..150218938 100644 --- a/examples/mqttc/mqttc_pub.c +++ b/examples/mqttc/mqttc_pub.c @@ -42,11 +42,11 @@ struct mqttc_cfg_s { struct mqtt_client client; - const FAR char *host; - const FAR char *port; - const FAR char *topic; - const FAR char *msg; - const FAR char *id; + FAR const char *host; + FAR const char *port; + FAR const char *topic; + FAR const char *msg; + FAR const char *id; uint8_t sendbuf[CONFIG_EXAMPLES_MQTTC_TXSIZE]; uint8_t recvbuf[CONFIG_EXAMPLES_MQTTC_RXSIZE]; uint32_t tmo; @@ -59,9 +59,9 @@ struct mqttc_cfg_s ****************************************************************************/ static FAR void *client_refresher(FAR void *data); -static void parsearg(int argc, char *argv[], struct mqttc_cfg_s *cfg, - int *n); -static int initserver(const FAR struct mqttc_cfg_s *cfg); +static void parsearg(int argc, FAR char *argv[], FAR struct mqttc_cfg_s *cfg, + FAR int *n); +static int initserver(FAR const struct mqttc_cfg_s *cfg); /**************************************************************************** * Private Functions @@ -95,7 +95,8 @@ static FAR void *client_refresher(FAR void *data) * ****************************************************************************/ -static void parsearg(int argc, char *argv[], struct mqttc_cfg_s *cfg, int *n) +static void parsearg(int argc, FAR char *argv[], + FAR struct mqttc_cfg_s *cfg, FAR int *n) { int opt; @@ -138,11 +139,11 @@ static void parsearg(int argc, char *argv[], struct mqttc_cfg_s *cfg, int *n) * ****************************************************************************/ -static int initserver(const FAR struct mqttc_cfg_s *cfg) +static int initserver(FAR const struct mqttc_cfg_s *cfg) { struct addrinfo hints; - struct addrinfo *servinfo; - struct addrinfo *itr; + FAR struct addrinfo *servinfo; + FAR struct addrinfo *itr; int fd; int ret; @@ -208,7 +209,7 @@ static int initserver(const FAR struct mqttc_cfg_s *cfg) * Public Functions ****************************************************************************/ -int main(int argc, char *argv[]) +int main(int argc, FAR char *argv[]) { int sockfd; enum MQTTErrors mqtterr; diff --git a/netutils/ftpd/ftpd.c b/netutils/ftpd/ftpd.c index 0fc840d64..fafe56145 100644 --- a/netutils/ftpd/ftpd.c +++ b/netutils/ftpd/ftpd.c @@ -484,7 +484,7 @@ ftpd_account_search_user(FAR struct ftpd_session_s *session, FAR const char *user) { FAR struct ftpd_account_s *newaccount = NULL; - const FAR struct ftpd_account_s *account; + FAR const struct ftpd_account_s *account; uint8_t accountflags; account = session->head; diff --git a/netutils/ftpd/ftpd.h b/netutils/ftpd/ftpd.h index a54469f20..31f3ca3e6 100644 --- a/netutils/ftpd/ftpd.h +++ b/netutils/ftpd/ftpd.h @@ -89,8 +89,8 @@ union ftpd_sockaddr_u struct ftpd_account_s { - struct ftpd_account_s *blink; - struct ftpd_account_s *flink; + FAR struct ftpd_account_s *blink; + FAR struct ftpd_account_s *flink; uint8_t flags; /* See FTPD_ACCOUNTFLAG_* definitions */ FAR char *user; /* User name */ FAR char *password; /* Un-encrypted password */ @@ -103,8 +103,8 @@ struct ftpd_server_s { int sd; /* Listen socket descriptor */ union ftpd_sockaddr_u addr; /* Listen address */ - struct ftpd_account_s *head; /* Head of a list of accounts */ - struct ftpd_account_s *tail; /* Tail of a list of accounts */ + FAR struct ftpd_account_s *head; /* Head of a list of accounts */ + FAR struct ftpd_account_s *tail; /* Tail of a list of accounts */ }; struct ftpd_stream_s @@ -118,8 +118,8 @@ struct ftpd_stream_s struct ftpd_session_s { - const FAR struct ftpd_server_s *server; - const FAR struct ftpd_account_s *head; + FAR const struct ftpd_server_s *server; + FAR const struct ftpd_account_s *head; bool loggedin; uint8_t flags; /* See TPD_SESSIONFLAG_* definitions */ int rxtimeout; @@ -149,7 +149,7 @@ struct ftpd_session_s FAR char *renamefrom; }; -typedef int (*ftpd_cmdhandler_t)(struct ftpd_session_s *); +typedef int (*ftpd_cmdhandler_t)(FAR struct ftpd_session_s *); struct ftpd_cmd_s { diff --git a/netutils/pppd/ppp.c b/netutils/pppd/ppp.c index 1c8f1970e..4325dc3a9 100644 --- a/netutils/pppd/ppp.c +++ b/netutils/pppd/ppp.c @@ -86,8 +86,9 @@ static void ppp_reject_protocol(FAR struct ppp_context_s *ctx, FAR uint8_t *sptr; FAR LCPPKT *pkt; - /* First copy rejected packet back, start from end and work forward, +++ Pay - * attention to buffer management when updated. Assumes fixed PPP blocks. + /* First copy rejected packet back, start from end and work forward, +++ + * Pay attention to buffer management when updated. Assumes fixed PPP + * blocks. */ DEBUG1(("Rejecting Protocol\n")); @@ -264,11 +265,11 @@ void ppp_poll(FAR struct ppp_context_s *ctx) #else if (ctx->lcp_state & LCP_RX_AUTH) { - /* lcp is asking for authentication but we do not support this. This - * should be communicated upstream but we do not have an interface - * for that right now, so just ignore it; nothing can be done. This - * also should not have been hit because upcall does not know about - * the pap message type. + /* lcp is asking for authentication but we do not support this. + * This should be communicated upstream but we do not have an + * interface for that right now, so just ignore it; nothing can be + * done. This also should not have been hit because upcall does + * not know about the pap message type. */ DEBUG1(("Asking for PAP, but we do not know PAP\n")); @@ -352,10 +353,10 @@ void ppp_upcall(FAR struct ppp_context_s *ctx, uint16_t protocol, ****************************************************************************/ uint16_t scan_packet(FAR struct ppp_context_s *ctx, uint16_t protocol, - FAR const FAR uint8_t * list, FAR uint8_t * buffer, + FAR const uint8_t * list, FAR uint8_t * buffer, FAR uint8_t * options, uint16_t len) { - FAR const FAR uint8_t *tlist; + FAR const uint8_t *tlist; FAR uint8_t *bptr; FAR uint8_t *tptr; uint8_t bad = 0; @@ -369,8 +370,8 @@ uint16_t scan_packet(FAR struct ppp_context_s *ctx, uint16_t protocol, while (bptr < options + len) { - /* Get code and see if it matches somewhere in the list, if not we don't - * support it. + /* Get code and see if it matches somewhere in the list, if not we + * don't support it. */ i = *bptr++; diff --git a/system/uniqueid/uniqueid_main.c b/system/uniqueid/uniqueid_main.c index bf94ec79b..631deb071 100644 --- a/system/uniqueid/uniqueid_main.c +++ b/system/uniqueid/uniqueid_main.c @@ -37,11 +37,11 @@ struct cfg_s { - const FAR char *delim; - const FAR char *format; + FAR const char *format; + FAR const char *delim; uint8_t positions[CONFIG_BOARDCTL_UNIQUEID_SIZE]; size_t count; - const FAR char *prefix; + FAR const char *prefix; }; /**************************************************************************** @@ -51,13 +51,13 @@ struct cfg_s static int parse_positions(FAR char *arg, FAR uint8_t *positions, FAR size_t *count) { - char *list_save; - char *list_item; - char *range_save; - char *range_item; - char *endptr; - int pos; - int pos2; + FAR char *list_save; + FAR char *list_item; + FAR char *range_save; + FAR char *range_item; + FAR char *endptr; + FAR int pos; + FAR int pos2; #define APPEND_POSITION(pos) \ do \ @@ -227,12 +227,13 @@ static int parsearg(int argc, FAR char *argv[], FAR struct cfg_s *cfg) int main(int argc, FAR char *argv[]) { uint8_t uniqueid[CONFIG_BOARDCTL_UNIQUEID_SIZE]; - char *formatter; + FAR char *formatter; int i; - struct cfg_s cfg = { - .format = "02x", - }; + struct cfg_s cfg = + { + "02x" + }; if (parsearg(argc, argv, &cfg) != 0) {