Skip to content

Commit

Permalink
fix format warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
korli committed Feb 5, 2025
1 parent e422380 commit 6d26bbd
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 49 deletions.
4 changes: 2 additions & 2 deletions source/AddOn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ AddOn::Close(bool client_quits)
status_t err = (*addon_close)();
if (err)
fprintf(
stderr, "Warning: add-on %s returned 0x%lx from addon_close()\n", fInfo.name, err);
stderr, "Warning: add-on %s returned 0x%" B_PRIx32 " from addon_close()\n", fInfo.name, err);
}

if (client_quits)
Expand Down Expand Up @@ -348,4 +348,4 @@ addon_refresh_config(void)
currentAddOn->SetTargetOfControlsRecurse(configView, configView);
}
currentAddOnWindow->Unlock();
}
}
14 changes: 7 additions & 7 deletions source/Becasso.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ Becasso::Becasso()
int clen = cdata[0];
NumColors = cdata[1] + 256 * cdata[2];
if (ShowColors && SHOW_EXTRA_COLOR_INFO) {
printf("Number of Color Names: %ld\n", NumColors);
printf("Number of Color Names: %" B_PRId32 "\n", NumColors);
printf("Max length of color name: %d\n", clen);
}
cdata += 3;
Expand Down Expand Up @@ -777,7 +777,7 @@ Becasso::ResolveSpecifier(
error.AddString("message", errorString);
message->SendReply(&error);
} else
fprintf(stderr, "%s\n", errorString);
fprintf(stderr, "%s\n", errorString.String());
}
}
break;
Expand Down Expand Up @@ -901,7 +901,7 @@ Becasso::MessageReceived(BMessage* message)
char dirname[B_FILE_NAME_LENGTH];
strcpy(dirname, appPath.Path());
char* argv[1];
argv[0] = new char[B_FILE_NAME_LENGTH];
argv[0] = new char[B_FILE_NAME_LENGTH + 34];
sprintf(argv[0], "file://%s/Documentation/Becasso.html", dirname);
be_roster->Launch("text/html", 1, argv);
break;
Expand Down Expand Up @@ -1671,7 +1671,7 @@ Becasso::MessageReceived(BMessage* message)
reply.AddInt32("result", NumTools);
message->SendReply(&reply);
} else
fprintf(stderr, "Number of Tools: %ld\n", NumTools);
fprintf(stderr, "Number of Tools: %" B_PRId32 "\n", NumTools);
break;
}
case PROP_MODE:
Expand All @@ -1682,7 +1682,7 @@ Becasso::MessageReceived(BMessage* message)
reply.AddInt32("result", NumModes);
message->SendReply(&reply);
} else
fprintf(stderr, "Number of Modes: %ld\n", NumModes);
fprintf(stderr, "Number of Modes: %" B_PRId32 "\n", NumModes);
break;
}
default:
Expand Down Expand Up @@ -1856,7 +1856,7 @@ Becasso::MessageReceived(BMessage* message)
break;
} else {
char errstring[256];
sprintf(errstring, "Mode Index Out of Range [0..%ld]: %ld",
sprintf(errstring, "Mode Index Out of Range [0..%" B_PRId32 "]: %" B_PRId32,
NumTools - 1, numberspecifier);
if (message->IsSourceWaiting()) {
BMessage error(B_ERROR);
Expand Down Expand Up @@ -2140,7 +2140,7 @@ Becasso::MessageReceived(BMessage* message)
}
} else {
char errstring[256];
sprintf(errstring, "Invalid Scriptee: Index %ld out of range [0..%ld]",
sprintf(errstring, "Invalid Scriptee: Index %" B_PRId32 " out of range [0..%" B_PRId32 "]",
indexspecifier, CountWindows() - 1);
if (message->IsSourceWaiting()) {
BMessage error(B_ERROR);
Expand Down
4 changes: 2 additions & 2 deletions source/CanvasTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ CanvasView::tBrushM(int32 mode, BPoint point, uint32 buttons, int strength, BPoi
end = clock();
extern int DebugLevel;
if (DebugLevel > 7)
printf("Brush Stroke took %ld ms\n", end - start);
printf("Brush Stroke took %" B_PRId32 " ms\n", end - start);
fBC.pos = pos;
}
// snooze (10000);
Expand Down Expand Up @@ -461,7 +461,7 @@ CanvasView::tCloneM(int32 mode, BPoint point, uint32 buttons, int strength, BPoi
end = clock();
extern int DebugLevel;
if (DebugLevel > 7)
printf("Clone Stroke took %ld ms\n", end - start);
printf("Clone Stroke took %" B_PRId32 " ms\n", end - start);
fCC.pos = pos;
}
}
Expand Down
16 changes: 8 additions & 8 deletions source/CanvasView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1206,7 +1206,7 @@ CanvasView::setLayerContentsToBitmap(int index, BBitmap* map, int32 resize)
end = clock();
extern int DebugLevel;
if (DebugLevel > 2)
printf("CanvasView::setLayerContentsToBitmap Took %ld ms\n", end - start);
printf("CanvasView::setLayerContentsToBitmap Took %" B_PRId32 " ms\n", end - start);
}

void
Expand Down Expand Up @@ -3376,7 +3376,7 @@ CanvasView::Invalidate(const BRect rect)
end = clock();
extern int DebugLevel;
if (DebugLevel > 7)
printf("Invalidate (BRect) took %ld ms\n", end - start);
printf("Invalidate (BRect) took %" B_PRId32 " ms\n", end - start);
}

void
Expand Down Expand Up @@ -3786,7 +3786,7 @@ CanvasView::MessageReceived(BMessage* msg)
error.AddString("result", layer[fLayerSpecifier]->getName());
msg->SendReply(&error);
} else
fprintf(stderr, "Layer %ld = %s\n", fLayerSpecifier,
fprintf(stderr, "Layer %" B_PRId32 " = %s\n", fLayerSpecifier,
layer[fLayerSpecifier]->getName());
}
fLayerSpecifier = -1;
Expand Down Expand Up @@ -3873,7 +3873,7 @@ CanvasView::MessageReceived(BMessage* msg)
end = clock();
extern int DebugLevel;
if (DebugLevel > 2)
printf("MessageReceived case Took %ld ms\n", end - start);
printf("MessageReceived case Took %" B_PRId32 " ms\n", end - start);
break;
}
default:
Expand Down Expand Up @@ -4756,7 +4756,7 @@ CanvasView::SetupUndo(int32 mode)
type = UNDO_BOTH;
break;
default:
fprintf(stderr, "SetupUndo: Unknown mode [%li]...\n", mode);
fprintf(stderr, "SetupUndo: Unknown mode [%" B_PRIi32 "]...\n", mode);
return;
}
if (type == UNDO_SELECT || type == UNDO_BOTH) {
Expand Down Expand Up @@ -4909,7 +4909,7 @@ CanvasView::Undo(bool advance, bool menu)
type = UNDO_SELECT;
break;
default:
fprintf(stderr, "Undo: Unknown mode [%li]...\n", currentmode);
fprintf(stderr, "Undo: Unknown mode [%" B_PRIi32 "]...\n", currentmode);
}
if ((prevtype == UNDO_DRAW && type == UNDO_SELECT)
|| (prevtype == UNDO_SELECT && type == UNDO_DRAW)) {
Expand Down Expand Up @@ -6309,7 +6309,7 @@ CanvasView::FastAddWithAlpha(long x, long y, int strength)
end = clock();
extern int DebugLevel;
if (DebugLevel > 7)
printf("FastAddWithAlpha took %ld ms\n", end - start);
printf("FastAddWithAlpha took %" B_PRId32 " ms\n", end - start);
}


Expand Down Expand Up @@ -6519,7 +6519,7 @@ CanvasView::ExportCstruct(const char* fname)
FILE* f = fopen(fname, "wb");
printf("Dumping to %s\n", fname);
fprintf(f, "/* C array for %s */\n", fname);
fprintf(f, "uchar data[%ld*%ld] = {\n ", fCanvasFrame.IntegerHeight() + 1,
fprintf(f, "uchar data[%" B_PRId32 "*%" B_PRId32 "] = {\n ", fCanvasFrame.IntegerHeight() + 1,
fCanvasFrame.IntegerWidth() + 1);
for (int i = 0; i <= fCanvasFrame.IntegerHeight(); i++) {
for (int j = 0; j <= fCanvasFrame.IntegerWidth(); j++) {
Expand Down
6 changes: 3 additions & 3 deletions source/CanvasWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1514,7 +1514,7 @@ CanvasWindow::MessageReceived(BMessage* message)
fName.SetTo(message->FindString("name"));
if (!out_type) {
fNumberFormat.FormatPercent(percentData, (double)fScale);
title.SetToFormat("%s (%s)", fName, percentData.String());
title.SetToFormat("%s (%s)", fName.String(), percentData.String());
SetTitle(title.String());
}
}
Expand All @@ -1527,7 +1527,7 @@ CanvasWindow::MessageReceived(BMessage* message)
BPoint(200, 200), lstring(155, "Writing Image…"));
BFile outStream;
if (outStream.SetTo(&entry, B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE))
printf("Error opening %s!\n", fName);
printf("Error opening %s!\n", fName.String());
bitmapStream->SetDispose(true);
#if defined(DATATYPES)
if (DATATranslate(*bitmapStream, &out_info, NULL, outStream, out_type)) {
Expand Down Expand Up @@ -2130,7 +2130,7 @@ CanvasWindow::MessageReceived(BMessage* message)
break;
default:
fprintf(
stderr, "Unknown addon requested preview: %li, type: %li\n", index, type);
stderr, "Unknown addon requested preview: %" B_PRId32 ", type: %" B_PRId32 "\n", index, type);
}
break;
}
Expand Down
14 changes: 7 additions & 7 deletions source/ColorMenuButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ trim_box(CMB_box* box, uint32* histogram)
CMB_box*
biggest_population(CMB_box* b, int boxindex)
{
int32 maxv = 0;
uint32 maxv = 0;
int i;

CMB_box* thebiggest = NULL;
Expand All @@ -359,7 +359,7 @@ biggest_population(CMB_box* b, int boxindex)
CMB_box*
biggest_volume(CMB_box* b, int boxindex)
{
int32 maxv = 0;
uint32 maxv = 0;
int i;

CMB_box* thebiggest = NULL;
Expand Down Expand Up @@ -463,7 +463,7 @@ ColorMenuButton::extractPalette(Layer* l, int max_col, bool clobber)
// (This shouldn't happen, because we test for #colors <= max_col first)

if (DebugLevel > 2)
printf("Biggest: %ld colors R[%d - %d] G[%d - %d] B[%d - %d]\n",
printf("Biggest: %" B_PRId32 " colors R[%d - %d] G[%d - %d] B[%d - %d]\n",
biggest->num_colors, biggest->rmin, biggest->rmax, biggest->gmin, biggest->gmax,
biggest->bmin, biggest->bmax);

Expand Down Expand Up @@ -515,22 +515,22 @@ ColorMenuButton::extractPalette(Layer* l, int max_col, bool clobber)
trim_box(n, histogram);
trim_box(biggest, histogram);
if (DebugLevel > 2)
printf(" After split: %ld colors R[%d - %d] G[%d - %d] B[%d - %d]\n",
printf(" After split: %" B_PRId32 " colors R[%d - %d] G[%d - %d] B[%d - %d]\n",
biggest->num_colors, biggest->rmin, biggest->rmax, biggest->gmin, biggest->gmax,
biggest->bmin, biggest->bmax);
if (DebugLevel > 2)
printf(" And: %ld colors R[%d - %d] G[%d - %d] B[%d - %d]\n",
printf(" And: %" B_PRId32 " colors R[%d - %d] G[%d - %d] B[%d - %d]\n",
n->num_colors, n->rmin, n->rmax, n->gmin, n->gmax, n->bmin, n->bmax);
}

if (DebugLevel)
fprintf(stderr, "Found %ld boxes. Calculating averages...\n", boxindex);
fprintf(stderr, "Found %" B_PRId32 " boxes. Calculating averages...\n", boxindex);

// Next, iterate over all the boxes and fill the color table with
// reasonable averages for the box colors.
for (int j = 0; j < max_col; j++) {
if (DebugLevel > 2)
printf("Box %i: %ld colors R[%d - %d] G[%d - %d] B[%d - %d]\n", j,
printf("Box %i: %" B_PRId32 " colors R[%d - %d] G[%d - %d] B[%d - %d]\n", j,
boxes[j].num_colors, boxes[j].rmin, boxes[j].rmax, boxes[j].gmin, boxes[j].gmax,
boxes[j].bmin, boxes[j].bmax);
uint32 fr, fg, fb;
Expand Down
3 changes: 2 additions & 1 deletion source/Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ if $(haver4stdc++) {
STDCPPLIBS = -lstdc++.r4 ;
}

C++FLAGS = -Wall ; # -g -O1 -fsanitize=address ;
LINKLIBS on Becasso = -lbe -lz -ltracker -ltranslation -lgame -ldevice $(STDCPPLIBS) ;
LINKFLAGS on Becasso = -Xlinker -soname=_APP_ ;
LINKFLAGS on Becasso = -Xlinker -soname=_APP_ ; # -fsanitize=address ;

AS = nasm -f elf32 ;

Expand Down
2 changes: 1 addition & 1 deletion source/OutputFormatWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ OutputFormatView::MessageReceived(BMessage* msg)
int32 ver = outVersion / 100;
int32 rev1 = (outVersion % 100) / 10;
int32 rev2 = outVersion % 10;
sprintf(version_line, "Version %ld.%ld.%ld", ver, rev1, rev2); // --SS %ld
sprintf(version_line, "Version %" B_PRId32 ".%" B_PRId32 ".%" B_PRId32, ver, rev1, rev2); // --SS %ld
info_lines[0] = name_line;
info_lines[1] = info_line;
info_lines[2] = version_line;
Expand Down
24 changes: 12 additions & 12 deletions source/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ PrefsLoader::PrefsLoader()
while (*ptr != '=')
ptr++;
ptr++;
if (sscanf(ptr, "%ld:", &index) == 1) {
if (sscanf(ptr, "%" B_PRId32 ":", &index) == 1) {
while (*ptr != ':')
ptr++;
ptr++;
Expand All @@ -232,32 +232,32 @@ PrefsLoader::PrefsLoader()
while (*ptr != '=')
ptr++;
ptr++;
if (sscanf(ptr, "%ld", &g_settings.recents) != 1)
if (sscanf(ptr, "%" B_PRId32, &g_settings.recents) != 1)
fprintf(
stderr, "Illegal # of Recent items in Becasso settings: %s\n", ptr);
} else if (!strcmp(name, "max_undo")) {
while (*ptr != '=')
ptr++;
ptr++;
if (sscanf(ptr, "%ld", &g_settings.max_undo) != 1)
if (sscanf(ptr, "%" B_PRId32, &g_settings.max_undo) != 1)
fprintf(stderr, "Illegal max_undo # in Becasso settings: %s\n", ptr);
} else if (!strcmp(name, "preview_size")) {
while (*ptr != '=')
ptr++;
ptr++;
if (sscanf(ptr, "%ld", &g_settings.preview_size) != 1)
if (sscanf(ptr, "%" B_PRId32, &g_settings.preview_size) != 1)
fprintf(stderr, "Illegal preview_size in Becasso settings: %s\n", ptr);
} else if (!strcmp(name, "totd")) {
while (*ptr != '=')
ptr++;
ptr++;
if (sscanf(ptr, "%ld", &g_settings.totd) != 1)
if (sscanf(ptr, "%" B_PRId32, &g_settings.totd) != 1)
fprintf(stderr, "Illegal totd number in Becasso settings: %s\n", ptr);
} else if (!strcmp(name, "selection_render")) {
while (*ptr != '=')
ptr++;
ptr++;
if (sscanf(ptr, "%ld", &g_settings.selection_type) != 1)
if (sscanf(ptr, "%" B_PRId32, &g_settings.selection_type) != 1)
fprintf(
stderr, "Illegal selection_render in Becasso settings: %s\n", ptr);
} else {
Expand Down Expand Up @@ -302,15 +302,15 @@ PrefsLoader::Save()
if (fp) {
fprintf(fp, "# Becasso settings - Sum Software (http://www.sumware.demon.nl)\n");
fprintf(fp, "language=%s\n", g_settings.language);
fprintf(fp, "recent_entries=%ld\n", g_settings.recents);
fprintf(fp, "max_undo=%ld\n", g_settings.max_undo);
fprintf(fp, "preview_size=%ld\n", g_settings.preview_size);
fprintf(fp, "selection_render=%ld\n", g_settings.selection_type);
fprintf(fp, "totd=%ld\n", g_settings.totd);
fprintf(fp, "recent_entries=%" B_PRId32 "\n", g_settings.recents);
fprintf(fp, "max_undo=%" B_PRId32 "\n", g_settings.max_undo);
fprintf(fp, "preview_size=%" B_PRId32 "\n", g_settings.preview_size);
fprintf(fp, "selection_render=%" B_PRId32 "\n", g_settings.selection_type);
fprintf(fp, "totd=%" B_PRId32 "\n", g_settings.totd);
for (int index = 0; index < NUM_WINDOWS; index++) {
BPoint origin = g_settings.origin[index];
if (origin != InvalidPoint)
fprintf(fp, "window_origin = %d:%g,%g\n", index, origin.x, origin.y);
fprintf(fp, "window_origin = %" B_PRId32 ":%g,%g\n", index, origin.x, origin.y);
}
fclose(fp);
} else
Expand Down
8 changes: 4 additions & 4 deletions source/add-ons/Mandelbrot/mandelbrot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ MandelView::MessageReceived(BMessage* msg)
case K_INVERT_MSG:
if (mIInvert)
mInvert = mIInvert->Value();
printf("mIInvert %p, value %ld\n", mIInvert, mIInvert->Value());
printf("mIInvert %p, value %" B_PRId32 "\n", mIInvert, mIInvert->Value());
break;
case K_ISOMORPH_MSG:
if (mIIsomorphic)
Expand Down Expand Up @@ -422,7 +422,7 @@ MandelView::displayAngle(void)
{
char s[64];
if (LockLooper()) {
sprintf(s, "%ld deg", mAngle);
sprintf(s, "%" B_PRId32 " deg", mAngle);
if (mIAngle)
mIAngle->SetText(s);
UnlockLooper();
Expand All @@ -437,10 +437,10 @@ MandelView::displayIter(void)
{
char s[64];
if (LockLooper()) {
sprintf(s, "%ld", mApplyIterations);
sprintf(s, "%" B_PRId32, mApplyIterations);
if (mIApplyIter)
mIApplyIter->SetText(s);
sprintf(s, "%ld", mPreviewIterations);
sprintf(s, "%" B_PRId32, mPreviewIterations);
if (mIPreviewIter)
mIPreviewIter->SetText(s);
UnlockLooper();
Expand Down
2 changes: 1 addition & 1 deletion source/add-ons/VideoGrabber/VideoConsumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ VideoConsumer::CreateBuffers(const media_format& with_format)
} // else PROGRESS("VideoConsumer::CreateBuffers - SUCCESSFUL ADD BUFFER TO GROUP\n");
} else {
ERROR(
"VideoConsumer::CreateBuffers - ERROR CREATING VIDEO RING BUFFER: %08lx\n", status
"VideoConsumer::CreateBuffers - ERROR CREATING VIDEO RING BUFFER: %08" B_PRIx32 "\n", status
);
return B_ERROR;
}
Expand Down
2 changes: 1 addition & 1 deletion source/add-ons/VideoGrabber/VideoGrabber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ void
ErrorAlert(const char* message, status_t err)
{
char msg[256];
sprintf(msg, "%s\n%s [%lx]", message, strerror(err), err);
sprintf(msg, "%s\n%s [%" B_PRIx32 "]", message, strerror(err), err);
(new BAlert("", msg, "Quit"))->Go();
}

Expand Down

0 comments on commit 6d26bbd

Please sign in to comment.