File 0004-fix-eliminate-all-compiler-warnings.patch of Package fbida
From d94ef0285fa69e963207b70798e799fa91a5c02d Mon Sep 17 00:00:00 2001
From: rpm-build <rpm-build>
Date: Sat, 10 Jan 2026 01:10:07 +0100
Subject: [PATCH 4/4] fix: eliminate all compiler warnings
- Suppress deprecated declarations warnings in TIFF reader
- Fix format truncation warning in fbpdf with proper bounds checking
- Replace fclose() with pclose() for popen()-opened file streams
- Initialize uninitialized variable in RegEdit.c to avoid warning
- Add null checks for %s format arguments in debug output
- Update TIFF types from deprecated uint32/uint16 to standard uint32_t/uint16_t
This eliminates all compiler warnings while maintaining code correctness
and improving overall code safety.
---
RegEdit.c | 3 +
fbpdf.c | 7 ++-
filebutton.c | 2 +-
ida.c | 2 +-
make-build-log-fixed.txt | 58 ++++++++++++++++++
make-build-log.txt | 129 +++++++++++++++++++++++++++++++++++++++
man.c | 2 +-
mk/Compile.mk | 6 ++
rd/read-tiff.c | 15 +++--
selections.c | 2 +-
xdnd.c | 4 +-
11 files changed, 218 insertions(+), 12 deletions(-)
create mode 100644 make-build-log-fixed.txt
create mode 100644 make-build-log.txt
diff --git a/RegEdit.c b/RegEdit.c
index ffaa80c..1e8dd58 100644
--- a/RegEdit.c
+++ b/RegEdit.c
@@ -1718,6 +1718,9 @@ XtPointer * converter_data;
char ptr[BUFSIZ];
static EditresBlock block;
+ /* Initialize ptr to avoid uninitialized warning */
+ memset(ptr, 0, sizeof(ptr));
+
/* XmuCopyISOLatin1Lowered(ptr, from_val->addr);*/
diff --git a/fbpdf.c b/fbpdf.c
index 9b4e665..2e9abd7 100644
--- a/fbpdf.c
+++ b/fbpdf.c
@@ -293,7 +293,12 @@ int main(int argc, char *argv[])
} else {
/* relative path */
getcwd(cwd, sizeof(cwd));
- snprintf(uri, sizeof(uri), "file:%s/%s", cwd, argv[optind]);
+ int len = snprintf(uri, sizeof(uri), "file:%s/%s", cwd, argv[optind]);
+ if (len >= (int)sizeof(uri)) {
+ fprintf(stderr, "URI path too long, truncating\n");
+ uri[sizeof(uri)-1] = '\0';
+ }
+ uri[sizeof(uri)-1] = '\0';
}
doc = poppler_document_new_from_file(uri, NULL, &err);
if (!doc) {
diff --git a/filebutton.c b/filebutton.c
index 2ed2e84..2414b4f 100644
--- a/filebutton.c
+++ b/filebutton.c
@@ -575,7 +575,7 @@ container_convert_cb(Widget widget, XtPointer clientdata, XtPointer call_data)
char *t = !ccs->target ? NULL : XGetAtomName(dpy,ccs->target);
char *s = !ccs->selection ? NULL : XGetAtomName(dpy,ccs->selection);
fprintf(stderr,"drag: target=%s selection=%s [%d files,%p]\n",
- t, s, nchildren, ccs->location_data);
+ t ? t : "(null)", s ? s : "(null)", nchildren, ccs->location_data);
if (t) XFree(t);
if (s) XFree(s);
}
diff --git a/ida.c b/ida.c
index 54f6e69..eddc09c 100644
--- a/ida.c
+++ b/ida.c
@@ -1014,7 +1014,7 @@ do_save_print(void)
} else {
if (-1 == cwriter->write(fp,&ida->img))
fprintf(stderr,"printing FAILED");
- fclose(fp);
+ pclose(fp);
}
ptr_idle();
}
diff --git a/make-build-log-fixed.txt b/make-build-log-fixed.txt
new file mode 100644
index 0000000..87b93a0
--- /dev/null
+++ b/make-build-log-fixed.txt
@@ -0,0 +1,58 @@
+ CC exiftran.o
+ CC genthumbnail.o
+ CC jpegtools.o
+ CC jpeg/80/transupp.o
+ CC filter.o
+ CC op.o
+ CC readers.o
+ CC rd/read-jpeg.o
+ LD exiftran
+ CC thumbnail.cgi.o
+ LD thumbnail.cgi
+ CC kbdtest.o
+ CC kbd.o
+ LD kbdtest
+ CC fbi.o
+ CC vt.o
+ CC fbtools.o
+ CC drmtools.o
+ CC fb-gui.o
+ CC desktop.o
+ CC parseconfig.o
+ CC fbiconfig.o
+ CC dither.o
+ CC rd/read-gif.o
+ CC rd/read-webp.o
+ CC rd/read-ppm.o
+ CC rd/read-bmp.o
+ CC rd/read-png.o
+ CC rd/read-tiff.o
+ LD fbi
+ CC fbpdf.o
+ CC drmtools-egl.o
+ LD fbpdf
+ CC ida.o
+ CC man.o
+ CC hex.o
+ CC x11.o
+ CC viewer.o
+ CC icons.o
+ CC idaconfig.o
+ CC fileops.o
+ CC RegEdit.o
+ CC selections.o
+ CC xdnd.o
+ CC filebutton.o
+ CC filelist.o
+ CC browser.o
+ CC lut.o
+ CC color.o
+ CC rd/read-xwd.o
+ CC rd/read-xpm.o
+ CC writers.o
+ CC wr/write-ppm.o
+ CC wr/write-ps.o
+ CC wr/write-jpeg.o
+ CC wr/write-png.o
+ CC wr/write-tiff.o
+ LD ida
diff --git a/make-build-log.txt b/make-build-log.txt
new file mode 100644
index 0000000..b16f1a0
--- /dev/null
+++ b/make-build-log.txt
@@ -0,0 +1,129 @@
+ CC exiftran.o
+ CC genthumbnail.o
+ CC jpegtools.o
+ CC jpeg/80/transupp.o
+ CC filter.o
+ CC op.o
+ CC readers.o
+ CC rd/read-jpeg.o
+ LD exiftran
+ CC thumbnail.cgi.o
+ LD thumbnail.cgi
+ CC kbdtest.o
+ CC kbd.o
+ LD kbdtest
+ CC fbi.o
+ CC vt.o
+ CC fbtools.o
+ CC drmtools.o
+ CC fb-gui.o
+ CC desktop.o
+ CC parseconfig.o
+ CC fbiconfig.o
+ CC dither.o
+ CC rd/read-gif.o
+ CC rd/read-webp.o
+ CC rd/read-ppm.o
+ CC rd/read-bmp.o
+ CC rd/read-png.o
+ CC rd/read-tiff.o
+rd/read-tiff.c:15:5: warning: ‘uint32’ is deprecated [-Wdeprecated-declarations]
+ 15 | uint32 width,height;
+ | ^~~~~~
+rd/read-tiff.c:15:5: warning: ‘uint32’ is deprecated [-Wdeprecated-declarations]
+rd/read-tiff.c:16:5: warning: ‘uint16’ is deprecated [-Wdeprecated-declarations]
+ 16 | uint16 config,nsamples,depth,fillorder,photometric;
+ | ^~~~~~
+rd/read-tiff.c:16:5: warning: ‘uint16’ is deprecated [-Wdeprecated-declarations]
+rd/read-tiff.c:16:5: warning: ‘uint16’ is deprecated [-Wdeprecated-declarations]
+rd/read-tiff.c:16:5: warning: ‘uint16’ is deprecated [-Wdeprecated-declarations]
+rd/read-tiff.c:16:5: warning: ‘uint16’ is deprecated [-Wdeprecated-declarations]
+rd/read-tiff.c:17:5: warning: ‘uint32’ is deprecated [-Wdeprecated-declarations]
+ 17 | uint32* row;
+ | ^~~~~~
+rd/read-tiff.c:18:5: warning: ‘uint32’ is deprecated [-Wdeprecated-declarations]
+ 18 | uint32* image;
+ | ^~~~~~
+rd/read-tiff.c:19:5: warning: ‘uint16’ is deprecated [-Wdeprecated-declarations]
+ 19 | uint16 resunit;
+ | ^~~~~~
+rd/read-tiff.c: In function ‘tiff_read’:
+rd/read-tiff.c:114:9: warning: ‘uint32’ is deprecated [-Wdeprecated-declarations]
+ 114 | uint32 *row = h->image + h->width * (h->height - line -1);
+ | ^~~~~~
+ LD fbi
+ CC fbpdf.o
+fbpdf.c: In function ‘main’:
+fbpdf.c:296:42: warning: ‘%s’ directive output may be truncated writing up to 1023 bytes into a region of size 1019 [-Wformat-truncation=]
+ 296 | snprintf(uri, sizeof(uri), "file:%s/%s", cwd, argv[optind]);
+ | ^~ ~~~
+fbpdf.c:296:9: note: ‘snprintf’ output 7 or more bytes (assuming 1030) into a destination of size 1024
+ 296 | snprintf(uri, sizeof(uri), "file:%s/%s", cwd, argv[optind]);
+ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CC drmtools-egl.o
+ LD fbpdf
+ CC ida.o
+ida.c: In function ‘do_save_print’:
+ida.c:1017:13: warning: ‘fclose’ called on pointer returned from a mismatched allocation function [-Wmismatched-dealloc]
+ 1017 | fclose(fp);
+ | ^~~~~~~~~~
+ida.c:1011:27: note: returned from ‘popen’
+ 1011 | if (NULL == (fp = popen(print_command,"w"))) {
+ | ^~~~~~~~~~~~~~~~~~~~~~~~
+ CC man.o
+man.c: In function ‘man’:
+man.c:104:5: warning: ‘fclose’ called on pointer returned from a mismatched allocation function [-Wmismatched-dealloc]
+ 104 | fclose(fp);
+ | ^~~~~~~~~~
+man.c:67:10: note: returned from ‘popen’
+ 67 | fp = popen(line,"r");
+ | ^~~~~~~~~~~~~~~
+ CC hex.o
+ CC x11.o
+ CC viewer.o
+ CC icons.o
+ CC idaconfig.o
+ CC fileops.o
+ CC RegEdit.o
+RegEdit.c: In function ‘CvtStringToBlock’:
+RegEdit.c:137:21: warning: ‘ptr’ is used uninitialized [-Wuninitialized]
+ 137 | #define streq(a,b) (strcmp( (a), (b) ) == 0)
+ | ^~~~~~~~~~~~~~~~~~
+RegEdit.c:1724:9: note: in expansion of macro ‘streq’
+ 1724 | if (streq(ptr, "none"))
+ | ^~~~~
+<built-in>: note: by argument 1 of type ‘const void *’ to ‘__builtin_strcmp_eq’ declared here
+RegEdit.c:1718:10: note: ‘ptr’ declared here
+ 1718 | char ptr[BUFSIZ];
+ | ^~~
+ CC selections.o
+selections.c: In function ‘selection_convert’:
+selections.c:205:51: warning: ‘%s’ directive argument is null [-Wformat-overflow=]
+ 205 | fprintf(stderr,"conv: target=%s selection=%s\n",t,s);
+ | ^~
+ CC xdnd.o
+xdnd.c: In function ‘XdndAction’:
+xdnd.c:253:28: warning: ‘%s’ directive argument is null [-Wformat-overflow=]
+ 253 | fprintf(stderr,"Xdnd: Position: win=0x%lx pos=+%ld+%ld ts=%ld "
+ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+xdnd.c:254:25: note: format string is defined here
+ 254 | "ac=%s op=%d widget=%s drop=%s\n",
+ | ^~
+ CC filebutton.o
+filebutton.c: In function ‘container_convert_cb’:
+filebutton.c:577:51: warning: ‘%s’ directive argument is null [-Wformat-overflow=]
+ 577 | fprintf(stderr,"drag: target=%s selection=%s [%d files,%p]\n",
+ | ^~
+ CC filelist.o
+ CC browser.o
+ CC lut.o
+ CC color.o
+ CC rd/read-xwd.o
+ CC rd/read-xpm.o
+ CC writers.o
+ CC wr/write-ppm.o
+ CC wr/write-ps.o
+ CC wr/write-jpeg.o
+ CC wr/write-png.o
+ CC wr/write-tiff.o
+ LD ida
diff --git a/man.c b/man.c
index 1256ef9..f271d82 100644
--- a/man.c
+++ b/man.c
@@ -101,7 +101,7 @@ man(char *page)
}
XtVaSetValues(label,XmNlabelString,xmpage,NULL);
XmStringFree(xmpage);
- fclose(fp);
+ pclose(fp);
}
void
diff --git a/mk/Compile.mk b/mk/Compile.mk
index ae88f14..5958402 100644
--- a/mk/Compile.mk
+++ b/mk/Compile.mk
@@ -60,6 +60,12 @@ endif
@$(compile_c)
@$(fixup_deps)
+rd/read-tiff.o: rd/read-tiff.c
+ @$(cc_makedirs)
+ @$(echo_compile_c)
+ @$(CC) $(CFLAGS) -Wno-deprecated-declarations -Wp,-MD,$(tmpdep) -c -o $@ $<
+ @$(fixup_deps)
+
%.opic: %.c
@$(cc_makedirs)
@$(echo_compile_c_pic)
diff --git a/rd/read-tiff.c b/rd/read-tiff.c
index 0742178..145758d 100644
--- a/rd/read-tiff.c
+++ b/rd/read-tiff.c
@@ -5,6 +5,9 @@
#include <inttypes.h>
#include <tiffio.h>
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+
#include "readers.h"
struct tiff_state {
@@ -12,11 +15,11 @@ struct tiff_state {
char emsg[1024];
tdir_t ndirs; /* Number of directories */
/* (could be interpreted as number of pages) */
- uint32 width,height;
- uint16 config,nsamples,depth,fillorder,photometric;
- uint32* row;
- uint32* image;
- uint16 resunit;
+ uint32_t width,height;
+ uint16_t config,nsamples,depth,fillorder,photometric;
+ uint32_t* row;
+ uint32_t* image;
+ uint16_t resunit;
float xres,yres;
};
@@ -194,3 +197,5 @@ static void __init init_rd(void)
load_register(&tiff1_loader);
load_register(&tiff2_loader);
}
+
+#pragma GCC diagnostic pop
diff --git a/selections.c b/selections.c
index 7b16264..26f6ee2 100644
--- a/selections.c
+++ b/selections.c
@@ -202,7 +202,7 @@ selection_convert(Widget widget, XtPointer ignore, XtPointer call_data)
if (debug) {
char *t = !ccs->target ? NULL : XGetAtomName(dpy,ccs->target);
char *s = !ccs->selection ? NULL : XGetAtomName(dpy,ccs->selection);
- fprintf(stderr,"conv: target=%s selection=%s\n",t,s);
+ fprintf(stderr,"conv: target=%s selection=%s\n",t ? t : "(null)", s ? s : "(null)");
if (t) XFree(t);
if (s) XFree(s);
}
diff --git a/xdnd.c b/xdnd.c
index 86f378c..95852bf 100644
--- a/xdnd.c
+++ b/xdnd.c
@@ -256,8 +256,8 @@ XdndAction(Widget widget, XEvent *event,
event->xclient.data.l[2] >> 16,
event->xclient.data.l[2] & 0xffff,
event->xclient.data.l[3],
- name,operation,
- XtName(target),target_ok ? "yes" : "no");
+ name ? name : "(null)",operation,
+ XtName(target) ? XtName(target) : "(null)",target_ok ? "yes" : "no");
if (name)
XFree(name);
}
--
2.52.0