Skip to content

Commit

Permalink
Fix several format strings
Browse files Browse the repository at this point in the history
This fixes five performance issues reported by Codacy:

    %u in format string (no. 2) requires 'unsigned int' but the argument type is 'signed int'.
    %u in format string (no. 1) requires 'unsigned int' but the argument type is 'signed int'.
    %d in format string (no. 1) requires 'int' but the argument type is 'unsigned int'.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed Aug 26, 2024
1 parent 4a37a02 commit 69724b5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/ccutil/unicharset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ bool UNICHARSET::load_via_fgets(
stream >> std::setw(255) >> unichar >> std::hex >> properties >> std::dec;
// stream.flags(std::ios::dec);
if (stream.fail()) {
fprintf(stderr, "%s:%u failed\n", __FILE__, __LINE__);
fprintf(stderr, "%s:%d failed\n", __FILE__, __LINE__);
return false;
}
auto position = stream.tellg();
Expand Down
2 changes: 1 addition & 1 deletion src/classify/clusttool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ void WritePrototype(FILE *File, uint16_t N, PROTOTYPE *Proto) {
fprintf(File, "insignificant ");
}
WriteProtoStyle(File, static_cast<PROTOSTYLE>(Proto->Style));
fprintf(File, "%6d\n\t", Proto->NumSamples);
fprintf(File, "%6u\n\t", Proto->NumSamples);
WriteNFloats(File, N, &Proto->Mean[0]);
fprintf(File, "\t");

Expand Down
6 changes: 3 additions & 3 deletions src/viewer/scrollview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ void ScrollView::Initialize(const char *name, int x_pos, int y_pos, int x_size,
// Set up an actual Window on the client side.
char message[kMaxMsgSize];
snprintf(message, sizeof(message),
"w%u = luajava.newInstance('com.google.scrollview.ui"
"w%d = luajava.newInstance('com.google.scrollview.ui"
".SVWindow','%s',%u,%u,%u,%u,%u,%u,%u)\n",
window_id_, window_name_, window_id_, x_pos, y_pos, x_size, y_size, x_canvas_size,
y_canvas_size);
Expand Down Expand Up @@ -393,7 +393,7 @@ void ScrollView::SendMsg(const char *format, ...) {
va_end(args);

char form[kMaxMsgSize];
snprintf(form, sizeof(form), "w%u:%s\n", window_id_, message);
snprintf(form, sizeof(form), "w%d:%s\n", window_id_, message);

stream_->Send(form);
}
Expand Down Expand Up @@ -532,7 +532,7 @@ void ScrollView::AlwaysOnTop(bool b) {
// Adds a message entry to the message box.
void ScrollView::AddMessage(const char *message) {
char form[kMaxMsgSize];
snprintf(form, sizeof(form), "w%u:%s", window_id_, message);
snprintf(form, sizeof(form), "w%d:%s", window_id_, message);

char *esc = AddEscapeChars(form);
SendMsg("addMessage(\"%s\")", esc);
Expand Down

0 comments on commit 69724b5

Please sign in to comment.