Christian T. Steigies
2024-08-15 21:10:01 UTC
Hi,
I need to fix this bug if we want to have amiga-fdisk in trixie:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1074807
The attached patch fixes the error and removes one of the warnings, I assume
that this is the correct solution?
There are a couple more warnings which will probably become errors in one of
the next gcc releases (We are at version 14? The last GCC version I
remember using was something like 2.9, and I still have 2.6.3 on 10 floppy
disks somewhere...). I am not sure how to get rid of those warnings.
gcc -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/home/cts/salsa/amiga-fdisk=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wall -pedantic -DUSE_READLINE=yes -I./include -Wdate-time -D_FORTIFY_SOURCE=2 -c -o amigastuff.o amigastuff.c
amigastuff.c: In function ârigiddisk_reorgâ:
amigastuff.c:859:20: warning: pointer targets in assignment from âLONG *â {aka âlong int *â} to âULONG *â {aka âlong unsigned int *â} differ in signedness [-Wpointer-sign]
859 | crk=&(FSHB(curr)->fhb_SegListBlocks);
| ^
gcc -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/home/cts/salsa/amiga-fdisk=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wall -pedantic -DUSE_READLINE=yes -I./include -Wdate-time -D_FORTIFY_SOURCE=2 -c -o fdisk.o fdisk.c
fdisk.c: In function âatonumâ:
fdisk.c:85:33: warning: format â%xâ expects argument of type âunsigned int *â, but argument 3 has type âint *â [-Wformat=]
85 | sscanf(s + 2, "%x", &n);
| ~^ ~~
| | |
| | int *
| unsigned int *
| %x
fdisk.c:87:33: warning: format â%oâ expects argument of type âunsigned int *â, but argument 3 has type âint *â [-Wformat=]
87 | sscanf(s + 1, "%o", &n);
| ~^ ~~
| | |
| | int *
| unsigned int *
| %o
I tried defining n in fdisk.c as unsigned int but this caused even more
warnings in other places. Do I have to cast the arguments in sscanf to
unsigned int? It wants "unsigned int *", is it as simple as this or is
there a better solution?
--- a/fdisk.c
+++ b/fdisk.c
@@ -82,9 +82,9 @@
/* 0x is hex, 0 is octal, everything else is decimal. */
if (strncmp(s, "0x", 2) == 0 || strncmp(s, "0X", 2) == 0)
- sscanf(s + 2, "%x", &n);
+ sscanf(s + 2, "%x", (unsigned int *) &n);
else if (s[0] == '0' && s[1])
- sscanf(s + 1, "%o", &n);
+ sscanf(s + 1, "%o", (unsigned int *) &n);
else {
d=s;
while (d[0]!=0) {
thanks,
Christian
I need to fix this bug if we want to have amiga-fdisk in trixie:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1074807
The attached patch fixes the error and removes one of the warnings, I assume
that this is the correct solution?
There are a couple more warnings which will probably become errors in one of
the next gcc releases (We are at version 14? The last GCC version I
remember using was something like 2.9, and I still have 2.6.3 on 10 floppy
disks somewhere...). I am not sure how to get rid of those warnings.
gcc -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/home/cts/salsa/amiga-fdisk=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wall -pedantic -DUSE_READLINE=yes -I./include -Wdate-time -D_FORTIFY_SOURCE=2 -c -o amigastuff.o amigastuff.c
amigastuff.c: In function ârigiddisk_reorgâ:
amigastuff.c:859:20: warning: pointer targets in assignment from âLONG *â {aka âlong int *â} to âULONG *â {aka âlong unsigned int *â} differ in signedness [-Wpointer-sign]
859 | crk=&(FSHB(curr)->fhb_SegListBlocks);
| ^
gcc -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/home/cts/salsa/amiga-fdisk=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wall -pedantic -DUSE_READLINE=yes -I./include -Wdate-time -D_FORTIFY_SOURCE=2 -c -o fdisk.o fdisk.c
fdisk.c: In function âatonumâ:
fdisk.c:85:33: warning: format â%xâ expects argument of type âunsigned int *â, but argument 3 has type âint *â [-Wformat=]
85 | sscanf(s + 2, "%x", &n);
| ~^ ~~
| | |
| | int *
| unsigned int *
| %x
fdisk.c:87:33: warning: format â%oâ expects argument of type âunsigned int *â, but argument 3 has type âint *â [-Wformat=]
87 | sscanf(s + 1, "%o", &n);
| ~^ ~~
| | |
| | int *
| unsigned int *
| %o
I tried defining n in fdisk.c as unsigned int but this caused even more
warnings in other places. Do I have to cast the arguments in sscanf to
unsigned int? It wants "unsigned int *", is it as simple as this or is
there a better solution?
--- a/fdisk.c
+++ b/fdisk.c
@@ -82,9 +82,9 @@
/* 0x is hex, 0 is octal, everything else is decimal. */
if (strncmp(s, "0x", 2) == 0 || strncmp(s, "0X", 2) == 0)
- sscanf(s + 2, "%x", &n);
+ sscanf(s + 2, "%x", (unsigned int *) &n);
else if (s[0] == '0' && s[1])
- sscanf(s + 1, "%o", &n);
+ sscanf(s + 1, "%o", (unsigned int *) &n);
else {
d=s;
while (d[0]!=0) {
thanks,
Christian