From afed6fe4a2240860ee2801e0c89811af0182493f Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Fri, 14 Jul 2017 21:03:04 +0200 Subject: [PATCH] cleanup: remove all uint use --- src/app-layer.c | 4 ++-- src/decode-afl.c | 6 ++++-- src/detect-engine-filedata-smtp.c | 3 ++- src/detect-engine-hcbd.c | 4 ++-- src/detect-engine-hsbd.c | 2 +- src/detect-engine-state.c | 14 ++++++------ src/detect-http-header-common.c | 4 ++-- src/detect-http-header-names.c | 3 ++- src/stream-tcp-list.c | 4 ++-- src/stream-tcp-reassemble.c | 10 ++++----- src/tm-threads.c | 2 +- src/tmqh-packetpool.c | 2 +- src/util-streaming-buffer.c | 36 +++++++++++++++---------------- 13 files changed, 49 insertions(+), 45 deletions(-) diff --git a/src/app-layer.c b/src/app-layer.c index 7a83eb60f8..dee505be76 100644 --- a/src/app-layer.c +++ b/src/app-layer.c @@ -499,8 +499,8 @@ static int TCPProtoDetect(ThreadVars *tv, AppLayerParserGetStreamDepth(f)); *alproto = *alproto_otherdir; - SCLogDebug("packet %u: pd done(us %u them %u), parser called (r==%d), APPLAYER_DETECT_PROTOCOL_ONLY_ONE_DIRECTION set", - (uint)p->pcap_cnt, *alproto, *alproto_otherdir, r); + SCLogDebug("packet %"PRIu64": pd done(us %u them %u), parser called (r==%d), APPLAYER_DETECT_PROTOCOL_ONLY_ONE_DIRECTION set", + p->pcap_cnt, *alproto, *alproto_otherdir, r); if (r < 0) goto failure; } diff --git a/src/decode-afl.c b/src/decode-afl.c index 16b3ab87e4..99551ef4e7 100644 --- a/src/decode-afl.c +++ b/src/decode-afl.c @@ -77,7 +77,8 @@ int DecoderParseDataFromFile(char *filename, DecoderFunc Decoder) { size_t size = fread(&buffer, 1, sizeof(buffer), fp); char outfilename[256]; - snprintf(outfilename, sizeof(outfilename), "dump/%u-%u.%u", (uint)ts.tv_sec, (uint)ts.tv_usec, cnt); + snprintf(outfilename, sizeof(outfilename), "dump/%u-%u.%u", + (unsigned int)ts.tv_sec, (unsigned int)ts.tv_usec, cnt); FILE *out_fp = fopen(outfilename, "w"); BUG_ON(out_fp == NULL); (void)fwrite(buffer, size, 1, out_fp); @@ -106,7 +107,8 @@ int DecoderParseDataFromFile(char *filename, DecoderFunc Decoder) { uint32_t x = 0; for (x = 0; x < cnt; x++) { char rmfilename[256]; - snprintf(rmfilename, sizeof(rmfilename), "dump/%u-%u.%u", (uint)ts.tv_sec, (uint)ts.tv_usec, x); + snprintf(rmfilename, sizeof(rmfilename), "dump/%u-%u.%u", + (unsigned int)ts.tv_sec, (unsigned int)ts.tv_usec, x); unlink(rmfilename); } diff --git a/src/detect-engine-filedata-smtp.c b/src/detect-engine-filedata-smtp.c index face62d9d6..f2790e4829 100644 --- a/src/detect-engine-filedata-smtp.c +++ b/src/detect-engine-filedata-smtp.c @@ -163,7 +163,8 @@ static const uint8_t *DetectEngineSMTPGetBufferForTX(uint64_t tx_id, /* updat inspected tracker */ curr_file->content_inspected = FileDataSize(curr_file); - SCLogDebug("content_inspected %u, offset %u", (uint)curr_file->content_inspected, (uint)det_ctx->smtp[index].offset); + SCLogDebug("content_inspected %"PRIu64", offset %"PRIu64, + curr_file->content_inspected, det_ctx->smtp[index].offset); buffer = det_ctx->smtp[index].buffer; *buffer_len = det_ctx->smtp[index].buffer_len; diff --git a/src/detect-engine-hcbd.c b/src/detect-engine-hcbd.c index 8a8eedbc54..6d511b629a 100644 --- a/src/detect-engine-hcbd.c +++ b/src/detect-engine-hcbd.c @@ -185,7 +185,7 @@ static const uint8_t *DetectEngineHCBDGetBufferForTX(htp_tx_t *tx, uint64_t tx_i if (htud->request_body.body_inspected > htp_state->cfg->request.inspect_min_size) { BUG_ON(htud->request_body.content_len_so_far < htud->request_body.body_inspected); uint64_t inspect_win = htud->request_body.content_len_so_far - htud->request_body.body_inspected; - SCLogDebug("inspect_win %u", (uint)inspect_win); + SCLogDebug("inspect_win %"PRIu64, inspect_win); if (inspect_win < htp_state->cfg->request.inspect_window) { uint64_t inspect_short = htp_state->cfg->request.inspect_window - inspect_win; if (htud->request_body.body_inspected < inspect_short) @@ -210,7 +210,7 @@ static const uint8_t *DetectEngineHCBDGetBufferForTX(htp_tx_t *tx, uint64_t tx_i *buffer_len = det_ctx->hcbd[index].buffer_len; *stream_start_offset = det_ctx->hcbd[index].offset; - SCLogDebug("buffer_len %u (%u)", *buffer_len, (uint)htud->request_body.content_len_so_far); + SCLogDebug("buffer_len %u (%"PRIu64")", *buffer_len, htud->request_body.content_len_so_far); end: return buffer; } diff --git a/src/detect-engine-hsbd.c b/src/detect-engine-hsbd.c index fdf76977fb..778802a5d9 100644 --- a/src/detect-engine-hsbd.c +++ b/src/detect-engine-hsbd.c @@ -190,7 +190,7 @@ static const uint8_t *DetectEngineHSBDGetBufferForTX(htp_tx_t *tx, uint64_t tx_i if (htud->response_body.body_inspected > htp_state->cfg->response.inspect_min_size) { BUG_ON(htud->response_body.content_len_so_far < htud->response_body.body_inspected); uint64_t inspect_win = htud->response_body.content_len_so_far - htud->response_body.body_inspected; - SCLogDebug("inspect_win %u", (uint)inspect_win); + SCLogDebug("inspect_win %"PRIu64, inspect_win); if (inspect_win < htp_state->cfg->response.inspect_window) { uint64_t inspect_short = htp_state->cfg->response.inspect_window - inspect_win; if (htud->response_body.body_inspected < inspect_short) diff --git a/src/detect-engine-state.c b/src/detect-engine-state.c index 957966c19d..8506f2a1ec 100644 --- a/src/detect-engine-state.c +++ b/src/detect-engine-state.c @@ -265,7 +265,7 @@ static int HasStoredSigs(const Flow *f, const uint8_t flags) continue; } if (tx_de_state->dir_state[flags & STREAM_TOSERVER ? 0 : 1].cnt != 0) { - SCLogDebug("tx %u has sigs present", (uint)inspect_tx_id); + SCLogDebug("tx %"PRIu64" has sigs present", inspect_tx_id); return 1; } } @@ -298,7 +298,7 @@ static void StoreStateTxHandleFiles(DetectEngineThreadCtx *det_ctx, Flow *f, DetectEngineState *destate, const uint8_t flags, const uint64_t tx_id, const uint16_t file_no_match) { - SCLogDebug("tx %u, file_no_match %u", (uint)tx_id, file_no_match); + SCLogDebug("tx %"PRIu64", file_no_match %u", tx_id, file_no_match); DeStateStoreFileNoMatchCnt(destate, file_no_match, flags); if (DeStateStoreFilestoreSigsCantMatch(det_ctx->sgh, destate, flags) == 1) { FileDisableStoringForTransaction(f, flags & (STREAM_TOCLIENT | STREAM_TOSERVER), tx_id); @@ -378,7 +378,7 @@ int DeStateDetectStartDetection(ThreadVars *tv, DetectEngineCtx *de_ctx, uint8_t offset = det_ctx->de_state_sig_array[s->num] & 0xef; uint64_t tx_id = AppLayerParserGetTransactionInspectId(f->alparser, flags); if (offset > 0) { - SCLogDebug("using stored_tx_id %u instead of %u", (uint)tx_id+offset, (uint)tx_id); + SCLogDebug("using stored_tx_id %"PRIu64" instead of %"PRIu64, tx_id+offset, tx_id); tx_id += offset; } if (offset == MAX_STORED_TXID_OFFSET) { @@ -388,7 +388,7 @@ int DeStateDetectStartDetection(ThreadVars *tv, DetectEngineCtx *de_ctx, uint64_t total_txs = AppLayerParserGetTxCnt(f, alstate); SCLogDebug("total_txs %"PRIu64, total_txs); - SCLogDebug("starting: start tx %u, packet %u", (uint)tx_id, (uint)p->pcap_cnt); + SCLogDebug("starting: start tx %"PRIu64", packet %"PRIu64, tx_id, p->pcap_cnt); det_ctx->stream_already_inspected = false; for (; tx_id < total_txs; tx_id++) { @@ -475,7 +475,7 @@ int DeStateDetectStartDetection(ThreadVars *tv, DetectEngineCtx *de_ctx, PACKET_ALERT_FLAG_STATE_MATCH|PACKET_ALERT_FLAG_TX); } alert_cnt = 1; - SCLogDebug("MATCH: tx %u packet %u", (uint)tx_id, (uint)p->pcap_cnt); + SCLogDebug("MATCH: tx %"PRIu64" packet %"PRIu64, tx_id, p->pcap_cnt); } /* if this is the last tx in our list, and it's incomplete: then @@ -483,8 +483,8 @@ int DeStateDetectStartDetection(ThreadVars *tv, DetectEngineCtx *de_ctx, int tx_is_done = (tx_progress >= AppLayerParserGetStateProgressCompletionStatus(alproto, flags)); - SCLogDebug("tx %u, packet %u, rule %u, alert_cnt %u, last tx %d, tx_is_done %d, next_tx_no_progress %d", - (uint)tx_id, (uint)p->pcap_cnt, s->num, alert_cnt, + SCLogDebug("tx %"PRIu64", packet %"PRIu64", rule %u, alert_cnt %u, last tx %d, tx_is_done %d, next_tx_no_progress %d", + tx_id, p->pcap_cnt, s->num, alert_cnt, TxIsLast(tx_id, total_txs), tx_is_done, next_tx_no_progress); /* store our state */ diff --git a/src/detect-http-header-common.c b/src/detect-http-header-common.c index 1ab9b73595..2495d057e7 100644 --- a/src/detect-http-header-common.c +++ b/src/detect-http-header-common.c @@ -119,7 +119,7 @@ static inline int CreateSpace(HttpHeaderThreadData *td, uint64_t size) while (td->buffers_size + extra < size) { extra += td->tx_step; } - SCLogDebug("adding %u to the buffer", (uint)extra); + SCLogDebug("adding %u to the buffer", extra); void *ptmp = SCRealloc(td->buffers, (td->buffers_size + extra) * sizeof(HttpHeaderBuffer)); @@ -144,7 +144,7 @@ int HttpHeaderExpandBuffer(HttpHeaderThreadData *td, while ((buf->size + extra) < (size + buf->len)) { extra += td->size_step; } - SCLogDebug("adding %u to the buffer", (uint)extra); + SCLogDebug("adding %"PRIuMAX" to the buffer", (uintmax_t)extra); uint8_t *new_buffer = SCRealloc(buf->buffer, buf->size + extra); if (unlikely(new_buffer == NULL)) { diff --git a/src/detect-http-header-names.c b/src/detect-http-header-names.c index b3ce019476..5410f15d89 100644 --- a/src/detect-http-header-names.c +++ b/src/detect-http-header-names.c @@ -120,7 +120,8 @@ static uint8_t *GetBufferForTX(htp_tx_t *tx, uint64_t tx_id, if (i + 1 == no_of_headers) size += 2; - SCLogDebug("size %u + buf->len %u vs buf->size %u", (uint)size, buf->len, buf->size); + SCLogDebug("size %"PRIuMAX" + buf->len %u vs buf->size %u", + (uintmax_t)size, buf->len, buf->size); if (size + buf->len > buf->size) { if (HttpHeaderExpandBuffer(hdr_td, buf, size) != 0) { return NULL; diff --git a/src/stream-tcp-list.c b/src/stream-tcp-list.c index 9b85add4f6..a9c7cc7cd2 100644 --- a/src/stream-tcp-list.c +++ b/src/stream-tcp-list.c @@ -89,8 +89,8 @@ static inline int InsertSegmentDataCustom(TcpStream *stream, TcpSegment *seg, ui uint64_t mydata_offset; StreamingBufferGetData(&stream->sb, &mydata, &mydata_len, &mydata_offset); - SCLogDebug("stream %p seg %p data in buffer %p of len %u and offset %u", - stream, seg, &stream->sb, mydata_len, (uint)mydata_offset); + SCLogDebug("stream %p seg %p data in buffer %p of len %u and offset %"PRIu64, + stream, seg, &stream->sb, mydata_len, mydata_offset); //PrintRawDataFp(stdout, mydata, mydata_len); } #endif diff --git a/src/stream-tcp-reassemble.c b/src/stream-tcp-reassemble.c index 3fbde40541..37c97bda79 100644 --- a/src/stream-tcp-reassemble.c +++ b/src/stream-tcp-reassemble.c @@ -1274,9 +1274,9 @@ void StreamReassembleRawUpdateProgress(TcpSession *ssn, Packet *p, uint64_t prog stream->flags &= ~STREAMTCP_STREAM_FLAG_TRIGGER_RAW; } else { - SCLogDebug("p->pcap_cnt %u: progress %u app %u raw %u tcp win %u", - (uint)p->pcap_cnt, (uint)progress, (uint)STREAM_APP_PROGRESS(stream), - (uint)STREAM_RAW_PROGRESS(stream), (uint)stream->window); + SCLogDebug("p->pcap_cnt %"PRIu64": progress %"PRIu64" app %"PRIu64" raw %"PRIu64" tcp win %"PRIu32, + p->pcap_cnt, progress, STREAM_APP_PROGRESS(stream), + STREAM_RAW_PROGRESS(stream), stream->window); } /* if we were told to accept no more raw data, we can mark raw as @@ -1534,8 +1534,8 @@ static int StreamReassembleRawDo(TcpSession *ssn, TcpStream *stream, //PrintRawDataFp(stdout, mydata, mydata_len); SCLogDebug("raw progress %"PRIu64, progress); - SCLogDebug("stream %p data in buffer %p of len %u and offset %u", - stream, &stream->sb, mydata_len, (uint)progress); + SCLogDebug("stream %p data in buffer %p of len %u and offset %"PRIu64, + stream, &stream->sb, mydata_len, progress); if (eof) { // inspect all remaining data, ack'd or not diff --git a/src/tm-threads.c b/src/tm-threads.c index 81de56c342..d87e148a84 100644 --- a/src/tm-threads.c +++ b/src/tm-threads.c @@ -2391,7 +2391,7 @@ void TmreadsGetMinimalTimestamp(struct timeval *ts) } SCMutexUnlock(&thread_store_lock); COPY_TIMESTAMP(&local, ts); - SCLogDebug("ts->tv_sec %u", (uint)ts->tv_sec); + SCLogDebug("ts->tv_sec %"PRIuMAX, (uintmax_t)ts->tv_sec); } #undef COPY_TIMESTAMP diff --git a/src/tmqh-packetpool.c b/src/tmqh-packetpool.c index a94ce20c4e..e3a2f0acea 100644 --- a/src/tmqh-packetpool.c +++ b/src/tmqh-packetpool.c @@ -589,5 +589,5 @@ void PacketPoolPostRunmodes(void) max_pending_return_packets = packets; SCLogDebug("detect threads %u, max packets %u, max_pending_return_packets %u", - threads, (uint)threads, max_pending_return_packets); + threads, threads, max_pending_return_packets); } diff --git a/src/util-streaming-buffer.c b/src/util-streaming-buffer.c index 4a84a556c6..1c8b6fef62 100644 --- a/src/util-streaming-buffer.c +++ b/src/util-streaming-buffer.c @@ -231,12 +231,12 @@ static int SBBUpdateLookForward(StreamingBuffer *sb, while (sbb->offset + sbb->len == sbb->next->offset) { - SCLogDebug("EndsAfter: gobble up next: %u/%u", (uint)sbb->next->offset, sbb->next->len); + SCLogDebug("EndsAfter: gobble up next: %"PRIu64"/%u", sbb->next->offset, sbb->next->len); uint64_t right_edge = sbb->next->offset + sbb->next->len; uint32_t expand_by = right_edge - (sbb->offset + sbb->len); sbb->len += expand_by; SCLogDebug("EndsAfter: expand_by %u (part 2)", expand_by); - SCLogDebug("EndsAfter: (loop) sbb now %u/%u", (uint)sbb->offset, sbb->len); + SCLogDebug("EndsAfter: (loop) sbb now %"PRIu64"/%u", sbb->offset, sbb->len); /* we can gobble up next */ StreamingBufferBlock *to_free = sbb->next; @@ -265,7 +265,7 @@ static int SBBUpdateLookForward(StreamingBuffer *sb, /* if next is not directly connected and we have some * block len left, expand sbb further */ uint32_t gap = sbb->next->offset - (sbb->offset + sbb->len); - SCLogDebug("EndsAfter: we now have a gap of %u and a block of %u/%u", gap, (uint)my_block->offset, my_block->len); + SCLogDebug("EndsAfter: we now have a gap of %u and a block of %"PRIu64"/%u", gap, my_block->offset, my_block->len); if (my_block->len < gap) { sbb->len += my_block->len; @@ -276,8 +276,8 @@ static int SBBUpdateLookForward(StreamingBuffer *sb, sbb->len += gap; my_block->offset += gap; my_block->len -= gap; - SCLogDebug("EndsAfter: (loop) block at %u/%u, sbb %u/%u", (uint)my_block->offset, my_block->len, (uint)sbb->offset, sbb->len); - SCLogDebug("EndsAfter: (loop) sbb->next %u/%u", (uint)sbb->next->offset, sbb->next->len); + SCLogDebug("EndsAfter: (loop) block at %"PRIu64"/%u, sbb %"PRIu64"/%u", my_block->offset, my_block->len, sbb->offset, sbb->len); + SCLogDebug("EndsAfter: (loop) sbb->next %"PRIu64"/%u", sbb->next->offset, sbb->next->len); } } } @@ -304,7 +304,7 @@ static void SBBUpdate(StreamingBuffer *sb, else if (tail && IsAfter(&my_block, tail)) { StreamingBufferBlock *new_sbb = GetNew(sb, my_block.offset, my_block.len, NULL); sb->block_list_tail = tail->next = new_sbb; - SCLogDebug("tail: new block at %u/%u", (uint)my_block.offset, my_block.len); + SCLogDebug("tail: new block at %"PRIu64"/%u", my_block.offset, my_block.len); goto done; } @@ -312,7 +312,7 @@ static void SBBUpdate(StreamingBuffer *sb, #ifdef DEBUG SBBPrintList(sb); #endif - SCLogDebug("PreInsert: block at %u/%u", (uint)my_block.offset, my_block.len); + SCLogDebug("PreInsert: block at %"PRIu64"/%u", my_block.offset, my_block.len); StreamingBufferBlock *sbb = sb->block_list, *prev = NULL; while (sbb) { SCLogDebug("sbb %"PRIu64"/%u data %"PRIu64"/%u. Next %s", sbb->offset, sbb->len, @@ -327,12 +327,12 @@ static void SBBUpdate(StreamingBuffer *sb, } else { prev->next = new_sbb; } - SCLogDebug("IsBefore: new block at %u/%u", (uint)my_block.offset, my_block.len); + SCLogDebug("IsBefore: new block at %"PRIu64"/%u", my_block.offset, my_block.len); break; } else if (IsOverlappedBy(&my_block, sbb)) { /* nothing to do */ - SCLogDebug("IsOverlappedBy: overlapped block at %u/%u", (uint)my_block.offset, my_block.len); + SCLogDebug("IsOverlappedBy: overlapped block at %"PRIu64"/%u", my_block.offset, my_block.len); break; } else if (IsAfter(&my_block, sbb)) { @@ -342,10 +342,10 @@ static void SBBUpdate(StreamingBuffer *sb, StreamingBufferBlock *new_sbb = GetNew(sb, my_block.offset, my_block.len, NULL); sbb->next = new_sbb; sb->block_list_tail = new_sbb; - SCLogDebug("new block at %u/%u", (uint)my_block.offset, my_block.len); + SCLogDebug("new block at %"PRIu64"/%u", my_block.offset, my_block.len); break; } - SCLogDebug("IsAfter: block at %u/%u, is after sbb", (uint)my_block.offset, my_block.len); + SCLogDebug("IsAfter: block at %"PRIu64"/%u, is after sbb", my_block.offset, my_block.len); } else { @@ -364,7 +364,7 @@ static void SBBUpdate(StreamingBuffer *sb, my_block.offset = sbb->offset + sbb->len; my_block.len = my_block_right_edge - my_block.offset; - SCLogDebug("StartsBefore: block now %u/%u", (uint)my_block.offset, my_block.len); + SCLogDebug("StartsBefore: block now %"PRIu64"/%u", my_block.offset, my_block.len); if (sbb->next == NULL) { sbb->len += my_block.len; @@ -379,11 +379,11 @@ static void SBBUpdate(StreamingBuffer *sb, expand_by = right_edge - (sbb->offset + sbb->len); SCLogDebug("EndsAfter: expand_by %u", expand_by); sbb->len += expand_by; - SCLogDebug("EndsAfter: sbb now %u/%u", (uint)sbb->offset, sbb->len); + SCLogDebug("EndsAfter: sbb now %"PRIu64"/%u", sbb->offset, sbb->len); my_block.offset = sbb->offset + sbb->len; my_block.len = my_block_right_edge - my_block.offset; - SCLogDebug("StartsBefore: sbb now %u/%u", (uint)sbb->offset, sbb->len); + SCLogDebug("StartsBefore: sbb now %"PRIu64"/%u", sbb->offset, sbb->len); } else if (EndsAfter(&my_block, sbb)) { /* expand sbb, but we need to mind "next" */ @@ -403,7 +403,7 @@ static void SBBUpdate(StreamingBuffer *sb, uint32_t expand_by = right_edge - (sbb->offset + sbb->len); SCLogDebug("EndsAfter: expand_by %u", expand_by); sbb->len += expand_by; - SCLogDebug("EndsAfter: sbb now %u/%u", (uint)sbb->offset, sbb->len); + SCLogDebug("EndsAfter: sbb now %"PRIu64"/%u", sbb->offset, sbb->len); my_block.offset = sbb->offset + sbb->len; my_block.len = my_block_right_edge - my_block.offset; @@ -416,7 +416,7 @@ static void SBBUpdate(StreamingBuffer *sb, goto done; } - SCLogDebug("EndsAfter: block at %u/%u, is after sbb", (uint)my_block.offset, my_block.len); + SCLogDebug("EndsAfter: block at %"PRIu64"/%u, is after sbb", my_block.offset, my_block.len); if (my_block.len == 0) break; @@ -425,7 +425,7 @@ static void SBBUpdate(StreamingBuffer *sb, sbb = sbb->next; } done: - SCLogDebug("PostInsert: block at %u/%u", (uint)my_block.offset, my_block.len); + SCLogDebug("PostInsert: block at %"PRIu64"/%u", my_block.offset, my_block.len); SCLogDebug("PostInsert"); #ifdef DEBUG SBBPrintList(sb); @@ -945,7 +945,7 @@ int StreamingBufferCompareRawData(const StreamingBuffer *sb, { return 1; } - SCLogDebug("sbdata_len %u, offset %u", sbdata_len, (uint)offset); + SCLogDebug("sbdata_len %u, offset %"PRIu64, sbdata_len, offset); printf("got:\n"); PrintRawDataFp(stdout, sbdata,sbdata_len); printf("wanted:\n");