From ac75aa5ccc6790eae0e625eb18b51a9333e5d402 Mon Sep 17 00:00:00 2001 From: Diomidis Spinellis Date: Sat, 30 Nov 2024 17:05:31 +0200 Subject: [PATCH] Fix Clang warnings --- src/cscout.cpp | 8 ++++---- src/funquery.cpp | 6 +++--- src/idquery.cpp | 2 +- src/md5.c | 14 ++++++-------- src/md5.h | 8 ++++---- src/option.cpp | 4 ++-- src/option.h | 2 +- src/os.cpp | 4 ++-- src/parse.y | 3 +-- src/pdtoken.cpp | 3 +-- src/query.cpp | 2 +- 11 files changed, 26 insertions(+), 30 deletions(-) diff --git a/src/cscout.cpp b/src/cscout.cpp index 87fb13ed..463cd345 100644 --- a/src/cscout.cpp +++ b/src/cscout.cpp @@ -1758,7 +1758,7 @@ explore_functions(FILE *fo, Call *f, if (((*i)->*fbegin)() != ((*i)->*fend)()) { /* Functions below; create +/- hyperlink. */ char param[1024]; - sprintf(param, "f%02d%p", level, &(**i)); + snprintf(param, sizeof(param), "f%02d%p", level, &(**i)); char *pval = swill_getvar(param); if (pval) { @@ -1829,14 +1829,14 @@ funlist_page(FILE *fo, void *p) fbegin = &Call::caller_begin; fend = &Call::caller_end; fprintf(fo, "List of %s calling functions\n", calltype); - sprintf(buff, " — call path from function", graph_suffix(), f); + snprintf(buff, sizeof(buff), " — call path from function", graph_suffix(), f); break; case 'd': case 'D': fbegin = &Call::call_begin; fend = &Call::call_end; fprintf(fo, "List of %s called functions\n", calltype); - sprintf(buff, " — call path to function", graph_suffix(), f); + snprintf(buff, sizeof(buff), " — call path to function", graph_suffix(), f); break; } if (swill_getvar("e")) { @@ -3599,7 +3599,7 @@ main(int argc, char *argv[]) cout << Sql::getInterface()->end_commands(); #ifdef LINUX_STAT_MONITOR char buff[100]; - sprintf(buff, "cat /proc/%u/stat >%u.stat", getpid(), getpid()); + snprintf(buff, sizeof(buff), "cat /proc/%u/stat >%u.stat", getpid(), getpid()); if (system(buff) != 0) { fprintf(stderr, "Unable to run %s\n", buff); exit(1); diff --git a/src/funquery.cpp b/src/funquery.cpp index 51244882..f81af4a2 100644 --- a/src/funquery.cpp +++ b/src/funquery.cpp @@ -161,7 +161,7 @@ FunQuery::param_url() const if (id_ec) { char buff[256]; - sprintf(buff, "&ec=%p", id_ec); + snprintf(buff, sizeof(buff), "&ec=%p", id_ec); r += buff; } else { r += "&match="; @@ -169,11 +169,11 @@ FunQuery::param_url() const } r += mquery.param_url(); if (call) { - sprintf(buff, "&call=%p", call); + snprintf(buff, sizeof(buff), "&call=%p", call); r += buff; } if (match_fid) { - sprintf(buff, "&fid=%d", fid.get_id()); + snprintf(buff, sizeof(buff), "&fid=%d", fid.get_id()); r += buff; } if (cfun) diff --git a/src/idquery.cpp b/src/idquery.cpp index 13087989..40f1c071 100644 --- a/src/idquery.cpp +++ b/src/idquery.cpp @@ -192,7 +192,7 @@ IdQuery::param_url() const if (ec) { char buff[256]; - sprintf(buff, "&ec=%p", ec); + snprintf(buff, sizeof(buff), "&ec=%p", ec); r += buff; } else { r += "&match="; diff --git a/src/md5.c b/src/md5.c index f6b43a1a..f1817089 100644 --- a/src/md5.c +++ b/src/md5.c @@ -105,8 +105,8 @@ static unsigned char PADDING[64] = { /* The routine MD5Init initializes the message-digest context mdContext. All fields are set to zero. */ -void MD5Init (mdContext) -MD5_CTX *mdContext; +void +MD5Init(MD5_CTX *mdContext) { mdContext->i[0] = mdContext->i[1] = (UINT4)0; @@ -122,10 +122,8 @@ MD5_CTX *mdContext; account for the presence of each of the characters inBuf[0..inLen-1] in the message whose digest is being computed. */ -void MD5Update (mdContext, inBuf, inLen) -MD5_CTX *mdContext; -unsigned char *inBuf; -unsigned int inLen; +void +MD5Update(MD5_CTX *mdContext, unsigned char *inBuf, unsigned int inLen) { UINT4 in[16]; int mdi; @@ -160,8 +158,8 @@ unsigned int inLen; /* The routine MD5Final terminates the message-digest computation and ends with the desired message digest in mdContext->digest[0...15]. */ -void MD5Final (mdContext) -MD5_CTX *mdContext; +void +MD5Final(MD5_CTX *mdContext) { UINT4 in[16]; int mdi; diff --git a/src/md5.h b/src/md5.h index fbac6234..efd5e0d2 100644 --- a/src/md5.h +++ b/src/md5.h @@ -59,10 +59,10 @@ typedef struct { unsigned char digest[16]; /* actual digest after MD5Final call */ } MD5_CTX; -void MD5Init (); -void MD5Update (); -void MD5Final (); -unsigned char * MD5File(const char *fname); +void MD5Init(MD5_CTX *mdContext); +void MD5Update(MD5_CTX *mdContext, unsigned char *inBuf, unsigned int inLen); +void MD5Final(MD5_CTX *mdContext); +unsigned char *MD5File(const char *fname); #ifdef __cplusplus } diff --git a/src/option.cpp b/src/option.cpp index 6c142426..bde6a68b 100644 --- a/src/option.cpp +++ b/src/option.cpp @@ -75,8 +75,8 @@ BoolOption *Option::cgraph_dot_url; // Include URLs in dot output vector