From d2744063a038510a43384340382de8e67b565d8c Mon Sep 17 00:00:00 2001 From: cpq Date: Fri, 9 Apr 2021 16:55:12 +0100 Subject: [PATCH] Remove unused MG_SWAPxx macros --- mongoose.c | 2 +- mongoose.h | 16 ++++++++-------- src/sock.c | 2 +- src/util.h | 16 ++++++++-------- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/mongoose.c b/mongoose.c index f3cf64d1..ae13286f 100644 --- a/mongoose.c +++ b/mongoose.c @@ -2938,8 +2938,8 @@ static int write_conn(struct mg_connection *c) { static void close_conn(struct mg_connection *c) { // Unlink this connection from the list - LIST_DELETE(struct mg_connection, &c->mgr->conns, c); mg_resolve_cancel(c); + LIST_DELETE(struct mg_connection, &c->mgr->conns, c); if (c == c->mgr->dns4.c) c->mgr->dns4.c = NULL; if (c == c->mgr->dns6.c) c->mgr->dns6.c = NULL; mg_call(c, MG_EV_CLOSE, NULL); diff --git a/mongoose.h b/mongoose.h index 39386542..26bbac40 100644 --- a/mongoose.h +++ b/mongoose.h @@ -511,10 +511,9 @@ FILE *mg_fopen(const char *fp, const char *mode); #define mg_htons(x) mg_ntohs(x) #define mg_htonl(x) mg_ntohl(x) -#define MG_SWAP16(x) ((((x) >> 8) & 255) | ((x & 255) << 8)) -#define MG_SWAP32(x) \ - (((x) >> 24) | (((x) &0xff0000) >> 8) | (((x) &0xff00) << 8) | ((x) << 24)) - +// WEAK symbol makes it possible to define a "default" function implementation, +// which could be overridden by the user who can define a function with the +// same name without linking conflict #if !defined(WEAK) #if (defined(__GNUC__) || defined(__clang__) || \ defined(__TI_COMPILER_VERSION__)) && \ @@ -532,7 +531,12 @@ FILE *mg_fopen(const char *fp, const char *mode); #else #define MG_STRINGIFY_LITERAL(x) #x #endif +// Expands to a string representation of its argument, which can be a macro: +// #define FOO 123 +// MG_STRINGIFY_MACRO(FOO) // Expands to 123 +#define MG_STRINGIFY_MACRO(x) MG_STRINGIFY_LITERAL(x) +// Linked list management macros #define LIST_ADD_HEAD(type_, head_, elem_) \ do { \ (elem_)->next = (*head_); \ @@ -553,10 +557,6 @@ FILE *mg_fopen(const char *fp, const char *mode); *h = (elem_)->next; \ } while (0) -// Expands to a string representation of its argument, which can be a macro: -// #define FOO 123 -// MG_STRINGIFY_MACRO(FOO) // Expands to 123 -#define MG_STRINGIFY_MACRO(x) MG_STRINGIFY_LITERAL(x) diff --git a/src/sock.c b/src/sock.c index 1f5c9826..1070c722 100644 --- a/src/sock.c +++ b/src/sock.c @@ -282,8 +282,8 @@ static int write_conn(struct mg_connection *c) { static void close_conn(struct mg_connection *c) { // Unlink this connection from the list - LIST_DELETE(struct mg_connection, &c->mgr->conns, c); mg_resolve_cancel(c); + LIST_DELETE(struct mg_connection, &c->mgr->conns, c); if (c == c->mgr->dns4.c) c->mgr->dns4.c = NULL; if (c == c->mgr->dns6.c) c->mgr->dns6.c = NULL; mg_call(c, MG_EV_CLOSE, NULL); diff --git a/src/util.h b/src/util.h index 08f16b0f..3d202738 100644 --- a/src/util.h +++ b/src/util.h @@ -37,10 +37,9 @@ FILE *mg_fopen(const char *fp, const char *mode); #define mg_htons(x) mg_ntohs(x) #define mg_htonl(x) mg_ntohl(x) -#define MG_SWAP16(x) ((((x) >> 8) & 255) | ((x & 255) << 8)) -#define MG_SWAP32(x) \ - (((x) >> 24) | (((x) &0xff0000) >> 8) | (((x) &0xff00) << 8) | ((x) << 24)) - +// WEAK symbol makes it possible to define a "default" function implementation, +// which could be overridden by the user who can define a function with the +// same name without linking conflict #if !defined(WEAK) #if (defined(__GNUC__) || defined(__clang__) || \ defined(__TI_COMPILER_VERSION__)) && \ @@ -58,7 +57,12 @@ FILE *mg_fopen(const char *fp, const char *mode); #else #define MG_STRINGIFY_LITERAL(x) #x #endif +// Expands to a string representation of its argument, which can be a macro: +// #define FOO 123 +// MG_STRINGIFY_MACRO(FOO) // Expands to 123 +#define MG_STRINGIFY_MACRO(x) MG_STRINGIFY_LITERAL(x) +// Linked list management macros #define LIST_ADD_HEAD(type_, head_, elem_) \ do { \ (elem_)->next = (*head_); \ @@ -79,7 +83,3 @@ FILE *mg_fopen(const char *fp, const char *mode); *h = (elem_)->next; \ } while (0) -// Expands to a string representation of its argument, which can be a macro: -// #define FOO 123 -// MG_STRINGIFY_MACRO(FOO) // Expands to 123 -#define MG_STRINGIFY_MACRO(x) MG_STRINGIFY_LITERAL(x)