From bc55fb27dca172fc78601a70b6991e745b6d3360 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Wed, 1 Sep 2010 12:04:07 +0200 Subject: [PATCH] Compiler warning fix for memory macro's. Small layout changes. --- src/app-layer-htp.c | 31 ++++++++++++++----------------- src/util-mem.h | 32 ++++++++++++++++---------------- 2 files changed, 30 insertions(+), 33 deletions(-) diff --git a/src/app-layer-htp.c b/src/app-layer-htp.c index f8742d780e..c77a93818b 100644 --- a/src/app-layer-htp.c +++ b/src/app-layer-htp.c @@ -183,27 +183,23 @@ void HTPStateFree(void *state) s->flags &=~ HTP_FLAG_NEW_BODY_SET; /* free the connection parser memory used by HTP library */ - if (s != NULL) { - if (s->connp != NULL) { - size_t i; - /* free the list of body chunks */ - if (s->connp->conn != NULL) { - for (i = 0; i < list_size(s->connp->conn->transactions); i++) { - htp_tx_t *tx = (htp_tx_t *)list_get(s->connp->conn->transactions, i); - if (tx != NULL) { - - SCHtpTxUserData *htud = (SCHtpTxUserData *) htp_tx_get_user_data(tx); - if (htud != NULL) { - HtpBodyFree(&htud->body); - SCFree(htud); - } - htp_tx_set_user_data(tx, NULL); - + if (s != NULL && s->connp != NULL) { + size_t i; + /* free the list of body chunks */ + if (s->connp->conn != NULL) { + for (i = 0; i < list_size(s->connp->conn->transactions); i++) { + htp_tx_t *tx = (htp_tx_t *)list_get(s->connp->conn->transactions, i); + if (tx != NULL) { + SCHtpTxUserData *htud = (SCHtpTxUserData *) htp_tx_get_user_data(tx); + if (htud != NULL) { + HtpBodyFree(&htud->body); + SCFree(htud); } + htp_tx_set_user_data(tx, NULL); } } - htp_connp_destroy_all(s->connp); } + htp_connp_destroy_all(s->connp); } SCFree(s); @@ -263,6 +259,7 @@ void HTPStateTransactionFree(void *state, uint16_t id) { /** * \brief Sets a flag that informs the HTP app layer that some module in the * engine needs the http request body data. + * \initonly */ void AppLayerHtpEnableRequestBodyCallback(void) { diff --git a/src/util-mem.h b/src/util-mem.h index ad7439beec..4adcd8abc0 100644 --- a/src/util-mem.h +++ b/src/util-mem.h @@ -52,7 +52,7 @@ SC_ATOMIC_EXTERN(unsigned int, engine_stage); ptrmem = malloc(a); \ if (ptrmem == NULL && a > 0) { \ SCLogError(SC_ERR_MEM_ALLOC, "SCMalloc failed: %s, while trying " \ - "to allocate %Zu bytes", strerror(errno), (size_t)a); \ + "to allocate %"PRIuMAX" bytes", strerror(errno), (uintmax_t)a); \ if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {\ SCLogError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting..."); \ exit(EXIT_FAILURE); \ @@ -61,8 +61,8 @@ SC_ATOMIC_EXTERN(unsigned int, engine_stage); \ global_mem += a; \ if (print_mem_flag == 1) \ - SCLogInfo("SCMalloc return at %p of size %"PRIdMAX, \ - ptrmem, (size_t)a); \ + SCLogInfo("SCMalloc return at %p of size %"PRIuMAX, \ + ptrmem, (uintmax_t)a); \ \ (void*)ptrmem; \ }) @@ -75,7 +75,7 @@ SC_ATOMIC_EXTERN(unsigned int, engine_stage); ptrmem = realloc(x, a); \ if (ptrmem == NULL && a > 0) { \ SCLogError(SC_ERR_MEM_ALLOC, "SCRealloc failed: %s, while trying " \ - "to allocate %Zu bytes", strerror(errno), (size_t)a); \ + "to allocate %"PRIuMAX" bytes", strerror(errno), (uintmax_t)a); \ if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {\ SCLogError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting..."); \ exit(EXIT_FAILURE); \ @@ -84,8 +84,8 @@ SC_ATOMIC_EXTERN(unsigned int, engine_stage); \ global_mem += a; \ if (print_mem_flag == 1) \ - SCLogInfo("SCRealloc return at %p (old:%p) of size %"PRIdMAX, \ - ptrmem, x, (size_t)a); \ + SCLogInfo("SCRealloc return at %p (old:%p) of size %"PRIuMAX, \ + ptrmem, x, (uintmax_t)a); \ \ (void*)ptrmem; \ }) @@ -98,7 +98,7 @@ SC_ATOMIC_EXTERN(unsigned int, engine_stage); ptrmem = calloc(nm, a); \ if (ptrmem == NULL && a > 0) { \ SCLogError(SC_ERR_MEM_ALLOC, "SCCalloc failed: %s, while trying " \ - "to allocate %Zu bytes", strerror(errno), (size_t)a); \ + "to allocate %"PRIuMAX" bytes", strerror(errno), (uintmax_t)a); \ if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {\ SCLogError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting..."); \ exit(EXIT_FAILURE); \ @@ -107,8 +107,8 @@ SC_ATOMIC_EXTERN(unsigned int, engine_stage); \ global_mem += a*nm; \ if (print_mem_flag == 1) \ - SCLogInfo("SCCalloc return at %p of size %Zu nm %"PRIdMAX, \ - ptrmem, (size_t)a, (size_t)nm); \ + SCLogInfo("SCCalloc return at %p of size %"PRIuMAX" nm %"PRIuMAX, \ + ptrmem, (uintmax_t)a, (uintmax_t)nm); \ \ (void*)ptrmem; \ }) @@ -122,7 +122,7 @@ SC_ATOMIC_EXTERN(unsigned int, engine_stage); if (ptrmem == NULL) { \ size_t len = strlen(a); \ SCLogError(SC_ERR_MEM_ALLOC, "SCStrdup failed: %s, while trying " \ - "to allocate %"PRIuMAX" bytes", strerror(errno), (size_t)len); \ + "to allocate %"PRIuMAX" bytes", strerror(errno), (uintmax_t)len); \ if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {\ SCLogError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting..."); \ exit(EXIT_FAILURE); \ @@ -131,8 +131,8 @@ SC_ATOMIC_EXTERN(unsigned int, engine_stage); \ global_mem += len; \ if (print_mem_flag == 1) \ - SCLogInfo("SCStrdup return at %p of size %"PRIdMAX, \ - ptrmem, (size_t)len); \ + SCLogInfo("SCStrdup return at %p of size %"PRIuMAX, \ + ptrmem, (uintmax_t)len); \ \ (void*)ptrmem; \ }) @@ -160,7 +160,7 @@ SC_ATOMIC_EXTERN(unsigned int, engine_stage); ptrmem = malloc(a); \ if (ptrmem == NULL && a > 0) { \ SCLogError(SC_ERR_MEM_ALLOC, "SCMalloc failed: %s, while trying " \ - "to allocate %Zu bytes", strerror(errno), (size_t)a); \ + "to allocate %"PRIuMAX" bytes", strerror(errno), (uintmax_t)a); \ if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {\ SCLogError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting..."); \ exit(EXIT_FAILURE); \ @@ -175,7 +175,7 @@ SC_ATOMIC_EXTERN(unsigned int, engine_stage); ptrmem = realloc(x, a); \ if (ptrmem == NULL && a > 0) { \ SCLogError(SC_ERR_MEM_ALLOC, "SCRealloc failed: %s, while trying " \ - "to allocate %Zu bytes", strerror(errno), (size_t)a); \ + "to allocate %"PRIuMAX" bytes", strerror(errno), (uintmax_t)a); \ if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {\ SCLogError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting..."); \ exit(EXIT_FAILURE); \ @@ -190,7 +190,7 @@ SC_ATOMIC_EXTERN(unsigned int, engine_stage); ptrmem = calloc(nm, a); \ if (ptrmem == NULL && a > 0) { \ SCLogError(SC_ERR_MEM_ALLOC, "SCCalloc failed: %s, while trying " \ - "to allocate %Zu bytes", strerror(errno), (size_t)a); \ + "to allocate %"PRIuMAX" bytes", strerror(errno), (uintmax_t)a); \ if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {\ SCLogError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting..."); \ exit(EXIT_FAILURE); \ @@ -206,7 +206,7 @@ SC_ATOMIC_EXTERN(unsigned int, engine_stage); if (ptrmem == NULL) { \ size_t len = strlen(a); \ SCLogError(SC_ERR_MEM_ALLOC, "SCStrdup failed: %s, while trying " \ - "to allocate %"PRIuMAX" bytes", strerror(errno), (size_t)len); \ + "to allocate %"PRIuMAX" bytes", strerror(errno), (uintmax_t)len); \ if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {\ SCLogError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting..."); \ exit(EXIT_FAILURE); \