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

Fails to compile with GCC-14: incompatible pointer type #1

Open
NHOrus opened this issue Apr 1, 2024 · 1 comment
Open

Fails to compile with GCC-14: incompatible pointer type #1

NHOrus opened this issue Apr 1, 2024 · 1 comment

Comments

@NHOrus
Copy link

NHOrus commented Apr 1, 2024

x86_64-pc-linux-gnu-gcc -DHAVE_CONFIG_H -I. -I../include -I../include    -O3 -pipe -march=native -fno-diagnostics-color -c resource.c
resource.c: In function ‘allocate_pci_resources’:
resource.c:299:28: error: passing argument 2 of ‘getdelim’ from incompatible pointer type [-Wincompatible-pointer-types]
  299 |    while( getdelim( &line, &lineMax, '\n', fp ) > 0 )
      |                            ^~~~~~~~
      |                            |
      |                            int *
In file included from resource.c:22:
/usr/include/stdio.h:694:47: note: expected ‘size_t * restrict’ {aka ‘long unsigned int * restrict’} but argument is of type ‘int *’
  694 |                            size_t *__restrict __n, int __delimiter,
      |                            ~~~~~~~~~~~~~~~~~~~^~~
x86_64-pc-linux-gnu-gcc -DHAVE_CONFIG_H -I. -I../include -I../include    -O3 -pipe -march=native -fno-diagnostics-color -c mysnprtf.c
resource.c: In function ‘alloc_system_resources’:
resource.c:357:7: warning: ignoring return value of ‘fscanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  357 |       fscanf(input, "%*[^\n]\n"); /* skip first line */
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~
@NHOrus
Copy link
Author

NHOrus commented Apr 27, 2024

Patch

--- isapnptools-1.27.orig/src/resource.c        2024-04-27 08:02:26.232607532 -0000
+++ isapnptools-1.27/src/resource.c     2024-04-27 08:04:14.600217480 -0000
@@ -285,7 +285,7 @@
 void allocate_pci_resources( void )
 {
    char *line = 0;
-   int lineMax = 0;
+   size_t lineMax = 0;
 
    FILE *fp = fopen( "/proc/bus/pci/devices", "rt" );
    if( !fp )
@@ -354,7 +354,7 @@
        int io_end;
     /* Avoid allocating DMA channels used by other devices in /proc. */
     if ((input = fopen("/proc/interrupts", "r")) != NULL) {
-      fscanf(input, "%*[^\n]\n"); /* skip first line */
+      (void)fscanf(input, "%*[^\n]\n"); /* skip first line */
       while (fscanf (input, "%d%*[^\n]\n", &interrupt_num) == 1) {
 #if 0
                  snprintf(progress_report_buf,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant