Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIXED] GCC warning on format strings #497

Merged
merged 1 commit into from
Dec 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/asynctimeout.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ int main(int argc, char **argv)

if (s != NATS_OK)
{
printf("Error: %d - %s\n", s, natsStatus_GetText(s));
printf("Error: %u - %s\n", s, natsStatus_GetText(s));
nats_PrintLastErrorStack(stderr);
}

Expand Down
6 changes: 3 additions & 3 deletions examples/connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ int main(int argc, char **argv)

if (s != NATS_OK)
{
printf("Error: %d - %s\n", s, natsStatus_GetText(s));
printf("Error: %u - %s\n", s, natsStatus_GetText(s));
nats_PrintLastErrorStack(stderr);
exit(1);
}
Expand Down Expand Up @@ -103,7 +103,7 @@ int main(int argc, char **argv)

if (s != NATS_OK)
{
printf("Error: %d - %s\n", s, natsStatus_GetText(s));
printf("Error: %u - %s\n", s, natsStatus_GetText(s));
nats_PrintLastErrorStack(stderr);
exit(1);
}
Expand Down Expand Up @@ -135,7 +135,7 @@ int main(int argc, char **argv)

if (s != NATS_OK)
{
printf("Error: %d - %s\n", s, natsStatus_GetText(s));
printf("Error: %u - %s\n", s, natsStatus_GetText(s));
nats_PrintLastErrorStack(stderr);
exit(1);
}
Expand Down
2 changes: 1 addition & 1 deletion examples/examples.h
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ parseArgs(int argc, char **argv, const char *usage)

if (s != NATS_OK)
{
printf("Error parsing arguments: %d - %s\n",
printf("Error parsing arguments: %u - %s\n",
s, natsStatus_GetText(s));

nats_PrintLastErrorStack(stderr);
Expand Down
4 changes: 2 additions & 2 deletions examples/js-pub.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ _jsPubErr(jsCtx *js, jsPubAckErr *pae, void *closure)
{
int *errors = (int*) closure;

printf("Error: %d - Code: %d - Text: %s\n", pae->Err, pae->ErrCode, pae->ErrText);
printf("Error: %u - Code: %u - Text: %s\n", pae->Err, pae->ErrCode, pae->ErrText);
printf("Original message: %.*s\n", natsMsg_GetDataLength(pae->Msg), natsMsg_GetData(pae->Msg));

*errors = (*errors + 1);
Expand Down Expand Up @@ -184,7 +184,7 @@ int main(int argc, char **argv)
}
if (s != NATS_OK)
{
printf("Error: %d - %s - jerr=%d\n", s, natsStatus_GetText(s), jerr);
printf("Error: %u - %s - jerr=%u\n", s, natsStatus_GetText(s), jerr);
nats_PrintLastErrorStack(stderr);
}

Expand Down
4 changes: 2 additions & 2 deletions examples/js-sub.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ onMsg(natsConnection *nc, natsSubscription *sub, natsMsg *msg, void *closure)
static void
asyncCb(natsConnection *nc, natsSubscription *sub, natsStatus err, void *closure)
{
printf("Async error: %d - %s\n", err, natsStatus_GetText(err));
printf("Async error: %u - %s\n", err, natsStatus_GetText(err));

natsSubscription_GetDropped(sub, (int64_t*) &dropped);
}
Expand Down Expand Up @@ -218,7 +218,7 @@ int main(int argc, char **argv)
}
else
{
printf("Error: %d - %s - jerr=%d\n", s, natsStatus_GetText(s), jerr);
printf("Error: %u - %s - jerr=%u\n", s, natsStatus_GetText(s), jerr);
nats_PrintLastErrorStack(stderr);
}

Expand Down
2 changes: 1 addition & 1 deletion examples/publisher.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ int main(int argc, char **argv)
}
else
{
printf("Error: %d - %s\n", s, natsStatus_GetText(s));
printf("Error: %u - %s\n", s, natsStatus_GetText(s));
nats_PrintLastErrorStack(stderr);
}

Expand Down
4 changes: 2 additions & 2 deletions examples/queuegroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ onMsg(natsConnection *nc, natsSubscription *sub, natsMsg *msg, void *closure)
static void
asyncCb(natsConnection *nc, natsSubscription *sub, natsStatus err, void *closure)
{
printf("Async error: %d - %s\n", err, natsStatus_GetText(err));
printf("Async error: %u - %s\n", err, natsStatus_GetText(err));
}

int main(int argc, char **argv)
Expand Down Expand Up @@ -127,7 +127,7 @@ int main(int argc, char **argv)
}
else
{
printf("Error: %d - %s\n", s, natsStatus_GetText(s));
printf("Error: %u - %s\n", s, natsStatus_GetText(s));
nats_PrintLastErrorStack(stderr);
}

Expand Down
4 changes: 2 additions & 2 deletions examples/replier.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ static void
asyncCb(natsConnection *nc, natsSubscription *sub, natsStatus err, void *closure)
{
if (print)
printf("Async error: %d - %s\n", err, natsStatus_GetText(err));
printf("Async error: %u - %s\n", err, natsStatus_GetText(err));

natsSubscription_GetDropped(sub, (int64_t*) &dropped);
}
Expand Down Expand Up @@ -143,7 +143,7 @@ int main(int argc, char **argv)
}
else
{
printf("Error: %d - %s\n", s, natsStatus_GetText(s));
printf("Error: %u - %s\n", s, natsStatus_GetText(s));
nats_PrintLastErrorStack(stderr);
}

Expand Down
2 changes: 1 addition & 1 deletion examples/requestor.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ int main(int argc, char **argv)
}
else
{
printf("Error: %d - %s\n", s, natsStatus_GetText(s));
printf("Error: %u - %s\n", s, natsStatus_GetText(s));
nats_PrintLastErrorStack(stderr);
}

Expand Down
4 changes: 2 additions & 2 deletions examples/subscriber.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ static void
asyncCb(natsConnection *nc, natsSubscription *sub, natsStatus err, void *closure)
{
if (print)
printf("Async error: %d - %s\n", err, natsStatus_GetText(err));
printf("Async error: %u - %s\n", err, natsStatus_GetText(err));

natsSubscription_GetDropped(sub, (int64_t*) &dropped);
}
Expand Down Expand Up @@ -128,7 +128,7 @@ int main(int argc, char **argv)
}
else
{
printf("Error: %d - %s\n", s, natsStatus_GetText(s));
printf("Error: %u - %s\n", s, natsStatus_GetText(s));
nats_PrintLastErrorStack(stderr);
}

Expand Down
2 changes: 1 addition & 1 deletion src/conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -3470,7 +3470,7 @@ _pushDrainErr(natsConnection *nc, natsStatus s, const char *errTxt)
if (nc->opts->asyncErrCb != NULL)
{
char tmp[256];
snprintf(tmp, sizeof(tmp), "Drain error: %s: %d (%s)", errTxt, s, natsStatus_GetText(s));
snprintf(tmp, sizeof(tmp), "Drain error: %s: %u (%s)", errTxt, s, natsStatus_GetText(s));
natsAsyncCb_PostErrHandler(nc, NULL, s, NATS_STRDUP(tmp));
}
natsConn_Unlock(nc);
Expand Down
4 changes: 2 additions & 2 deletions src/js.c
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,7 @@ jsSub_deleteConsumerAfterDrain(natsSubscription *sub)
if (nc->opts->asyncErrCb != NULL)
{
char tmp[256];
snprintf(tmp, sizeof(tmp), "failed to delete consumer '%s': %d (%s)",
snprintf(tmp, sizeof(tmp), "failed to delete consumer '%s': %u (%s)",
consumer, s, natsStatus_GetText(s));
natsAsyncCb_PostErrHandler(nc, sub, s, NATS_STRDUP(tmp));
}
Expand Down Expand Up @@ -2515,7 +2515,7 @@ _recreateOrderedCons(void *closure)
if (nc->opts->asyncErrCb != NULL)
{
char tmp[256];
snprintf(tmp, sizeof(tmp), "failed recreating ordered consumer: %d (%s)",
snprintf(tmp, sizeof(tmp), "failed recreating ordered consumer: %u (%s)",
s, natsStatus_GetText(s));
natsAsyncCb_PostErrHandler(nc, sub, s, NATS_STRDUP(tmp));
}
Expand Down
4 changes: 2 additions & 2 deletions src/nats.c
Original file line number Diff line number Diff line change
Expand Up @@ -1253,7 +1253,7 @@ nats_GetVersionNumber(void)
static void
_versionGetString(char *buffer, size_t bufLen, uint32_t verNumber)
{
snprintf(buffer, bufLen, "%d.%d.%d",
snprintf(buffer, bufLen, "%u.%u.%u",
((verNumber >> 16) & 0xF),
((verNumber >> 8) & 0xF),
(verNumber & 0xF));
Expand Down Expand Up @@ -1593,7 +1593,7 @@ nats_PrintLastErrorStack(FILE *file)
if ((errTL == NULL) || (errTL->sts == NATS_OK) || (errTL->framesCount == -1))
return;

fprintf(file, "Error: %d - %s",
fprintf(file, "Error: %u - %s",
errTL->sts, natsStatus_GetText(errTL->sts));
if (errTL->text[0] != '\0')
fprintf(file, " - %s", errTL->text);
Expand Down
2 changes: 1 addition & 1 deletion src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,7 @@ natsParser_Parse(natsConnection *nc, char* buf, int bufLen)
natsMutex_Lock(nc->mu);

snprintf(nc->errStr, sizeof(nc->errStr),
"Parse Error [%d]: '%.*s'",
"Parse Error [%u]: '%.*s'",
nc->ps->state,
bufLen - i,
buf + i);
Expand Down
2 changes: 1 addition & 1 deletion test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -11263,7 +11263,7 @@ test_Flush(void)
if ((s == NATS_OK) && (args[i].s != NATS_OK))
{
s = args[i].s;
printf("t=%d s=%d\n", i, s);
printf("t=%d s=%u\n", i, s);
}
}
if (s == NATS_OK)
Expand Down