Skip to content

Commit

Permalink
Fix Clang warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
dspinellis committed Nov 30, 2024
1 parent ac1cd5a commit ac75aa5
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 30 deletions.
8 changes: 4 additions & 4 deletions src/cscout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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, " &mdash; <a href=\"cpath%s?from=%%p&to=%p\">call path from function</a>", graph_suffix(), f);
snprintf(buff, sizeof(buff), " &mdash; <a href=\"cpath%s?from=%%p&to=%p\">call path from function</a>", 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, " &mdash; <a href=\"cpath%s?from=%p&to=%%p\">call path to function</a>", graph_suffix(), f);
snprintf(buff, sizeof(buff), " &mdash; <a href=\"cpath%s?from=%p&to=%%p\">call path to function</a>", graph_suffix(), f);
break;
}
if (swill_getvar("e")) {
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/funquery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,19 +161,19 @@ 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=";
r += Query::url(string(1, match_type));
}
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)
Expand Down
2 changes: 1 addition & 1 deletion src/idquery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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=";
Expand Down
14 changes: 6 additions & 8 deletions src/md5.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/md5.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions src/option.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ BoolOption *Option::cgraph_dot_url; // Include URLs in dot output
vector<Option *> Option::options; // Options in the order they were added
map<string, Option *> Option::omap; // For loading options

SelectionOption::SelectionOption(const char *sn, const char *un, char iv, ...) :
Option(sn, un), v(iv)
SelectionOption::SelectionOption(const char *sn, const char *un, int iv, ...) :
Option(sn, un), v((char)iv)
{
va_list marker;
va_start(marker, iv);
Expand Down
2 changes: 1 addition & 1 deletion src/option.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class SelectionOption : public Option {
* Construct from name, short name, initial value, and a NULL-terminated list
* list of arguments of the form "letter:Description"
*/
SelectionOption(const char *sn, const char *un, char iv, ...);
SelectionOption(const char *sn, const char *un, int iv, ...);
// Save to a file
void save(ofstream &ofs) const { ofs << v; }
// Load from a file
Expand Down
4 changes: 2 additions & 2 deletions src/os.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ get_uniq_fname_string(const char *name)
*/
Error::error(E_FATAL, "Unable to stat file " + s, false);
}
sprintf(buff, "%ld:%ld", (long)sb.st_dev, (long)sb.st_ino);
snprintf(buff, sizeof(buff), "%ld:%ld", (long)sb.st_dev, (long)sb.st_ino);
if (DP())
cout << "uniq fname " << name << " = " << buff << "\n";
return (buff);
Expand All @@ -125,7 +125,7 @@ get_full_path(const char *name)
if (name[0] != '/') {
// Relative path
(void)getcwd(wd, sizeof(wd));
sprintf(buff, "%s/%s", wd, name);
snprintf(buff, sizeof(buff), "%s/%s", wd, name);
return (buff);
} else
return (name);
Expand Down
3 changes: 1 addition & 2 deletions src/parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -2737,9 +2737,8 @@ yacc_variable:
}
| '$' INT_CONST
{
const char *num = $2.get_name().c_str();
char *endptr;
int val = strtol(num, &endptr, 0);
int val = strtol($2.get_name().c_str(), &endptr, 0);
if ((unsigned)val >= yacc_dollar.size()) {
/*
* @error
Expand Down
3 changes: 1 addition & 2 deletions src/pdtoken.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1070,8 +1070,7 @@ Pdtoken::process_pragma()
return;
}
char *endptr;
unsigned long offset = strtoul(t.get_val().c_str(), &endptr, 0);
offset += 0; // silence the compiler warning
(void)strtoul(t.get_val().c_str(), &endptr, 0);
// XXX now do the work
} else if (t.get_val() == "nosync") {
// XXX now do the work
Expand Down
2 changes: 1 addition & 1 deletion src/query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Query::url(const string &s)
else {
char buff[4];

sprintf(buff, "%%%02x", (unsigned)*i);
snprintf(buff, sizeof(buff), "%%%02x", (unsigned)*i);
r += buff;
}
return r;
Expand Down

0 comments on commit ac75aa5

Please sign in to comment.