On IRIX with cc, I'm seeing a compilation failure:

  CC       getprogname.o
cc-1140 cc: ERROR File = ../../lib/getprogname.c, Line = 167
  A value of type "unsigned int" cannot be used to initialize an entity of type
          "char *".

            char *namesize = sizeof buf.pr_fname;
                             ^

cc-1164 cc: ERROR File = ../../lib/getprogname.c, Line = 168
  Argument of type "char *" is incompatible with parameter of type "size_t".

            char *namenul = memchr (name, '\0', namesize);
                                                ^

cc-1042 cc: ERROR File = ../../lib/getprogname.c, Line = 169
  The types of operands "int" and "char *" are incompatible.

            size_t namelen = namenul ? namenul - name : namesize;
                                                      ^

3 errors detected in the compilation of "../../lib/getprogname.c".


This patch fixes it.


2017-11-11  Bruno Haible  <[email protected]>

        getprogname: Fix compilation error on IRIX.
        * lib/getprogname.c (getprogname) [__sgi]: Fix type of local variable
        'namesize'.

diff --git a/lib/getprogname.c b/lib/getprogname.c
index 9c2ad36..ff61918 100644
--- a/lib/getprogname.c
+++ b/lib/getprogname.c
@@ -164,7 +164,7 @@ getprogname (void)
       if (ioctl_ok)
         {
           char *name = buf.pr_fname;
-          char *namesize = sizeof buf.pr_fname;
+          size_t namesize = sizeof buf.pr_fname;
           char *namenul = memchr (name, '\0', namesize);
           size_t namelen = namenul ? namenul - name : namesize;
           char *namecopy = malloc (namelen + 1);


Reply via email to