From 6b2fb3fd5da11641b3c607184c3d538a9d833d8c Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Fri, 21 Aug 2015 09:48:42 +0200 Subject: [PATCH] Fix minor format string issues --- src/app-layer-detect-proto.c | 4 ++-- src/decode-tcp.h | 2 +- src/detect-engine-iponly.c | 2 +- src/detect-engine-siggroup.c | 2 +- src/log-droplog.c | 4 ++-- src/runmode-erf-file.c | 4 ++-- src/runmode-pcap-file.c | 4 ++-- src/tm-threads.c | 2 +- src/util-byte.c | 12 ++++++------ src/util-decode-asn1.c | 2 +- src/util-runmodes.c | 18 +++++++++--------- 11 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/app-layer-detect-proto.c b/src/app-layer-detect-proto.c index 9545dffac7..ed029e5e6b 100644 --- a/src/app-layer-detect-proto.c +++ b/src/app-layer-detect-proto.c @@ -645,7 +645,7 @@ void AppLayerProtoDetectPrintProbingParsers(AppLayerProtoDetectProbingParser *pp else if (pp->ipproto == IPPROTO_UDP) printf("IPProto: UDP\n"); else - printf("IPProto: %"PRIu16"\n", pp->ipproto); + printf("IPProto: %"PRIu8"\n", pp->ipproto); pp_port = pp->port; for ( ; pp_port != NULL; pp_port = pp_port->next) { @@ -934,7 +934,7 @@ static void AppLayerProtoDetectInsertNewProbingParser(AppLayerProtoDetectProbing while (curr_pe != NULL) { if (curr_pe->alproto == alproto) { SCLogError(SC_ERR_ALPARSER, "Duplicate pp registered - " - "ipproto - %"PRIu16" Port - %"PRIu16" " + "ipproto - %"PRIu8" Port - %"PRIu16" " "App Protocol - NULL, App Protocol(ID) - " "%"PRIu16" min_depth - %"PRIu16" " "max_dept - %"PRIu16".", diff --git a/src/decode-tcp.h b/src/decode-tcp.h index 152d5103f4..29c02dfb2f 100644 --- a/src/decode-tcp.h +++ b/src/decode-tcp.h @@ -66,7 +66,7 @@ #define TCP_OPTS_CNT tcpvars.tcp_opt_cnt #define TCP_GET_RAW_OFFSET(tcph) (((tcph)->th_offx2 & 0xf0) >> 4) -#define TCP_GET_RAW_X2(tcph) ((tcph)->th_offx2 & 0x0f) +#define TCP_GET_RAW_X2(tcph) (unsigned char)((tcph)->th_offx2 & 0x0f) #define TCP_GET_RAW_SRC_PORT(tcph) ntohs((tcph)->th_sport) #define TCP_GET_RAW_DST_PORT(tcph) ntohs((tcph)->th_dport) diff --git a/src/detect-engine-iponly.c b/src/detect-engine-iponly.c index bfbbb0f4b3..06983fc015 100644 --- a/src/detect-engine-iponly.c +++ b/src/detect-engine-iponly.c @@ -484,7 +484,7 @@ static void SigNumArrayPrint(void *tmp) for (; i < 8; i++) { if (bitarray & 0x01) - printf(", %"PRIu16"", u * 8 + i); + printf(", %"PRIu32"", u * 8 + i); else printf(", "); diff --git a/src/detect-engine-siggroup.c b/src/detect-engine-siggroup.c index a7ecbafd9a..02602d908e 100644 --- a/src/detect-engine-siggroup.c +++ b/src/detect-engine-siggroup.c @@ -1225,7 +1225,7 @@ void SigGroupHeadPrintSigs(DetectEngineCtx *de_ctx, SigGroupHead *sgh) for (u = 0; u < (sgh->init->sig_size * 8); u++) { if (sgh->init->sig_array[u / 8] & (1 << (u % 8))) { SCLogDebug("%" PRIu32, u); - printf("s->num %"PRIu16" ", u); + printf("s->num %"PRIu32" ", u); } } diff --git a/src/log-droplog.c b/src/log-droplog.c index 1ee2d999f7..6eafd9d5ef 100644 --- a/src/log-droplog.c +++ b/src/log-droplog.c @@ -244,11 +244,11 @@ static int LogDropLogNetFilter (ThreadVars *tv, const Packet *p, void *data) break; case IPPROTO_ICMP: if (PKT_IS_ICMPV4(p)) { - fprintf(dlt->file_ctx->fp, " TYPE=%"PRIu16" CODE=%"PRIu16"" + fprintf(dlt->file_ctx->fp, " TYPE=%"PRIu8" CODE=%"PRIu8"" " ID=%"PRIu16" SEQ=%"PRIu16"", ICMPV4_GET_TYPE(p), ICMPV4_GET_CODE(p), ICMPV4_GET_ID(p), ICMPV4_GET_SEQ(p)); } else if(PKT_IS_ICMPV6(p)) { - fprintf(dlt->file_ctx->fp, " TYPE=%"PRIu16" CODE=%"PRIu16"" + fprintf(dlt->file_ctx->fp, " TYPE=%"PRIu8" CODE=%"PRIu8"" " ID=%"PRIu16" SEQ=%"PRIu16"", ICMPV6_GET_TYPE(p), ICMPV6_GET_CODE(p), ICMPV6_GET_ID(p), ICMPV6_GET_SEQ(p)); } diff --git a/src/runmode-erf-file.c b/src/runmode-erf-file.c index ef7d2e09ec..19dbb683df 100644 --- a/src/runmode-erf-file.c +++ b/src/runmode-erf-file.c @@ -202,8 +202,8 @@ int RunModeErfFileAutoFp(void) } for (thread = 0; thread < thread_max; thread++) { - snprintf(tname, sizeof(tname), "Detect%"PRIu16, thread+1); - snprintf(qname, sizeof(qname), "pickup%"PRIu16, thread+1); + snprintf(tname, sizeof(tname), "Detect%d", thread+1); + snprintf(qname, sizeof(qname), "pickup%d", thread+1); SCLogDebug("tname %s, qname %s", tname, qname); diff --git a/src/runmode-pcap-file.c b/src/runmode-pcap-file.c index d337cb9711..fab14639b3 100644 --- a/src/runmode-pcap-file.c +++ b/src/runmode-pcap-file.c @@ -217,8 +217,8 @@ int RunModeFilePcapAutoFp(void) } for (thread = 0; thread < thread_max; thread++) { - snprintf(tname, sizeof(tname), "Detect%"PRIu16, thread+1); - snprintf(qname, sizeof(qname), "pickup%"PRIu16, thread+1); + snprintf(tname, sizeof(tname), "Detect%d", thread+1); + snprintf(qname, sizeof(qname), "pickup%d", thread+1); SCLogDebug("tname %s, qname %s", tname, qname); diff --git a/src/tm-threads.c b/src/tm-threads.c index f0f8a3cf0a..c6828b4071 100644 --- a/src/tm-threads.c +++ b/src/tm-threads.c @@ -991,7 +991,7 @@ TmEcode TmThreadSetupOptions(ThreadVars *tv) tv->thread_priority = taf->prio; } SCLogInfo("Setting prio %d for \"%s\" Module to cpu/core " - "%"PRIu16", thread id %lu", tv->thread_priority, + "%d, thread id %lu", tv->thread_priority, tv->name, cpu, SCGetThreadIdLong()); } else { SetCPUAffinitySet(&taf->cpu_set); diff --git a/src/util-byte.c b/src/util-byte.c index 6f0cd13231..1d8e088a6a 100644 --- a/src/util-byte.c +++ b/src/util-byte.c @@ -207,7 +207,7 @@ int ByteExtractStringUint32(uint32_t *res, int base, uint16_t len, const char *s if ((uint64_t)(*res) != i64) { SCLogError(SC_ERR_NUMERIC_VALUE_ERANGE, "Numeric value out of range " - "(%" PRIu64 " > %" PRIu32 ")", i64, UINT_MAX); + "(%" PRIu64 " > %" PRIuMAX ")", i64, (uintmax_t)UINT_MAX); return -1; } @@ -228,7 +228,7 @@ int ByteExtractStringUint16(uint16_t *res, int base, uint16_t len, const char *s if ((uint64_t)(*res) != i64) { SCLogError(SC_ERR_NUMERIC_VALUE_ERANGE, "Numeric value out of range " - "(%" PRIu64 " > %" PRIu16 ")", i64, USHRT_MAX); + "(%" PRIu64 " > %" PRIuMAX ")", i64, (uintmax_t)USHRT_MAX); return -1; } @@ -249,7 +249,7 @@ int ByteExtractStringUint8(uint8_t *res, int base, uint16_t len, const char *str if ((uint64_t)(*res) != i64) { SCLogError(SC_ERR_NUMERIC_VALUE_ERANGE, "Numeric value out of range " - "(%" PRIu64 " > %" PRIu8 ")", i64, UCHAR_MAX); + "(%" PRIu64 " > %" PRIuMAX ")", i64, (uintmax_t)UCHAR_MAX); return -1; } @@ -326,7 +326,7 @@ int ByteExtractStringInt32(int32_t *res, int base, uint16_t len, const char *str if ((int64_t)(*res) != i64) { SCLogError(SC_ERR_NUMERIC_VALUE_ERANGE, "Numeric value out of range " - "(%" PRIi64 " > %" PRIi32 ")\n", i64, INT_MAX); + "(%" PRIi64 " > %" PRIiMAX ")\n", i64, (intmax_t)INT_MAX); return -1; } @@ -347,7 +347,7 @@ int ByteExtractStringInt16(int16_t *res, int base, uint16_t len, const char *str if ((int64_t)(*res) != i64) { SCLogError(SC_ERR_NUMERIC_VALUE_ERANGE, "Numeric value out of range " - "(%" PRIi64 " > %" PRIi16 ")\n", i64, SHRT_MAX); + "(%" PRIi64 " > %" PRIiMAX ")\n", i64, (intmax_t)SHRT_MAX); return -1; } @@ -368,7 +368,7 @@ int ByteExtractStringInt8(int8_t *res, int base, uint16_t len, const char *str) if ((int64_t)(*res) != i64) { SCLogError(SC_ERR_NUMERIC_VALUE_ERANGE, "Numeric value out of range " - "(%" PRIi64 " > %" PRIi8 ")\n", i64, CHAR_MAX); + "(%" PRIi64 " > %" PRIiMAX ")\n", i64, (intmax_t)CHAR_MAX); return -1; } diff --git a/src/util-decode-asn1.c b/src/util-decode-asn1.c index 6766af66c5..3372b517ce 100644 --- a/src/util-decode-asn1.c +++ b/src/util-decode-asn1.c @@ -319,7 +319,7 @@ void SCPrintByteBin(uint8_t byte) { uint8_t i = 0; for (i = 8; i > 0; i--) { - printf("%"PRIu8, ((byte >> (i - 1)) & 0x01)); + printf("%"PRIu8, (uint8_t)((byte >> (i - 1)) & 0x01)); if (i == 5) printf(" "); } diff --git a/src/util-runmodes.c b/src/util-runmodes.c index 5e89f7b28d..c9b61e6a2e 100644 --- a/src/util-runmodes.c +++ b/src/util-runmodes.c @@ -90,7 +90,7 @@ char *RunmodeAutoFpCreatePickupQueuesString(int n) if (strlen(queues) > 0) strlcat(queues, ",", queues_size); - snprintf(qname, sizeof(qname), "pickup%"PRIu16, thread+1); + snprintf(qname, sizeof(qname), "pickup%d", thread+1); strlcat(queues, qname, queues_size); } @@ -147,7 +147,7 @@ int RunModeSetLiveCaptureAutoFp(ConfigIfaceParserFunc ConfigParser, /* create the threads */ for (thread = 0; thread < threads_count; thread++) { - snprintf(tname, sizeof(tname), "%s%"PRIu16, thread_name, thread+1); + snprintf(tname, sizeof(tname), "%s%d", thread_name, thread+1); char *thread_name = SCStrdup(tname); if (unlikely(thread_name == NULL)) { SCLogError(SC_ERR_MEM_ALLOC, "Can't allocate thread name"); @@ -209,7 +209,7 @@ int RunModeSetLiveCaptureAutoFp(ConfigIfaceParserFunc ConfigParser, threads_count = ModThreadsCount(aconf); for (thread = 0; thread < threads_count; thread++) { - snprintf(tname, sizeof(tname), "%s%s%"PRIu16, thread_name, + snprintf(tname, sizeof(tname), "%s%s%d", thread_name, live_dev, thread+1); char *thread_name = SCStrdup(tname); if (unlikely(thread_name == NULL)) { @@ -249,8 +249,8 @@ int RunModeSetLiveCaptureAutoFp(ConfigIfaceParserFunc ConfigParser, } for (thread = 0; thread < thread_max; thread++) { - snprintf(tname, sizeof(tname), "Detect%"PRIu16, thread+1); - snprintf(qname, sizeof(qname), "pickup%"PRIu16, thread+1); + snprintf(tname, sizeof(tname), "Detect%d", thread+1); + snprintf(qname, sizeof(qname), "pickup%d", thread+1); SCLogDebug("tname %s, qname %s", tname, qname); @@ -341,7 +341,7 @@ static int RunModeSetLiveCaptureWorkersForDevice(ConfigIfaceThreadsCountFunc Mod if (single_mode) { snprintf(tname, sizeof(tname), "%s", thread_name); } else { - snprintf(tname, sizeof(tname), "%s%s%"PRIu16, + snprintf(tname, sizeof(tname), "%s%s%d", thread_name, live_dev, thread+1); } n_thread_name = SCStrdup(tname); @@ -557,8 +557,8 @@ int RunModeSetIPSAutoFp(ConfigIPSParserFunc ConfigParser, } for (thread = 0; thread < thread_max; thread++) { - snprintf(tname, sizeof(tname), "Detect%"PRIu16, thread+1); - snprintf(qname, sizeof(qname), "pickup%"PRIu16, thread+1); + snprintf(tname, sizeof(tname), "Detect%d", thread+1); + snprintf(qname, sizeof(qname), "pickup%d", thread+1); SCLogDebug("tname %s, qname %s", tname, qname); @@ -612,7 +612,7 @@ int RunModeSetIPSAutoFp(ConfigIPSParserFunc ConfigParser, /* create the threads */ for (int i = 0; i < nqueue; i++) { memset(tname, 0, sizeof(tname)); - snprintf(tname, sizeof(tname), "Verdict%"PRIu16, i); + snprintf(tname, sizeof(tname), "Verdict%d", i); char *thread_name = SCStrdup(tname); if (unlikely(thread_name == NULL)) {