bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

careadlinkatcwd's signature


From: Bruno Haible
Subject: careadlinkatcwd's signature
Date: Sun, 5 Jun 2011 14:03:43 +0200
User-agent: KMail/1.9.9

Hi Paul,

On AIX 7.1 with gcc, I get this warning:

  areadlink.c:38: warning: passing argument 6 of 'careadlinkat' from 
incompatible pointer type

The reason is obviously that 'readlinkat' has a return type of 'int', but
careadlinkat() expects a function pointer that has a return type of ssize_t.

There are two possible fixes:
  - Change the return type of that function pointer to 'int'.
  - Change the return type of careadlinkatcwd to 'ssize_t' always.

The second fix seems cleaner to me, and actually simplifies the code. Here's a
proposed patch. In a first step I enabled careadlinkatcwd as a function that
invokes readlinkat() when it exists. But then, there is no benefit in invoking
readlinkat when you can also invoke readlink.


2011-06-05  Bruno Haible  <address@hidden>

        careadlinkat: Avoid mismatch between ssize_t and int.
        * lib/careadlinkat.h (careadlinkatcwd): Declare as a function always.
        * lib/careadlinkat.c (careadlinkatcwd): Define always.

--- lib/careadlinkat.c.orig     Sun Jun  5 13:57:52 2011
+++ lib/careadlinkat.c  Sun Jun  5 13:56:10 2011
@@ -39,7 +39,6 @@
 
 #include "allocator.h"
 
-#if ! HAVE_READLINKAT
 /* Get the symbolic link value of FILENAME and put it into BUFFER, with
    size BUFFER_SIZE.  This function acts like readlink  but has
    readlinkat's signature.  */
@@ -53,7 +52,6 @@
     abort ();
   return readlink (filename, buffer, buffer_size);
 }
-#endif
 
 /* Assuming the current directory is FD, get the symbolic link value
    of FILENAME as a null-terminated string and put it into a buffer.
--- lib/careadlinkat.h.orig     Sun Jun  5 13:57:52 2011
+++ lib/careadlinkat.h  Sun Jun  5 13:55:21 2011
@@ -57,7 +57,6 @@
    Pass FD = AT_FDCWD and PREADLINKAT = careadlinkatcwd.  */
 #if HAVE_READLINKAT
 /* AT_FDCWD is declared in <fcntl.h>, readlinkat in <unistd.h>.  */
-# define careadlinkatcwd readlinkat
 #else
 /* Define AT_FDCWD independently, so that the careadlinkat module does
    not depend on the fcntl-h module.  The value does not matter, since
@@ -66,8 +65,8 @@
 # ifndef AT_FDCWD
 #  define AT_FDCWD (-3041965)
 # endif
+#endif
 ssize_t careadlinkatcwd (int fd, char const *filename,
                          char *buffer, size_t buffer_size);
-#endif
 
 #endif /* _GL_CAREADLINKAT_H */

-- 
In memoriam Eduard Lederer <http://de.wikipedia.org/wiki/Eduard_Lederer>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]