11102 rtld: NULL pointer errors

Review Request #1883 — Created May 31, 2019 and submitted

tsoome
illumos-gate
11102
6fc54c4...
general
In file included from /code/illumos-gate/proto/root_i386/usr/include/iso/time_iso.h:49:0,
                 from /code/illumos-gate/proto/root_i386/usr/include/time.h:40,
                 from /code/illumos-gate/proto/root_i386/usr/include/sys/time.h:462,
                 from /code/illumos-gate/proto/root_i386/usr/include/sys/select.h:53,
                 from /code/illumos-gate/proto/root_i386/usr/include/sys/types.h:640,
                 from ../../common/_rtld.h:37,
                 from ../common/rtld.c:27:
../common/rtld.c: In function 'rtmap_format':
/code/illumos-gate/proto/root_i386/usr/include/sys/null.h:32:14: error: passing argument 4 of 'mdb_call_dcmd' makes integer from pointer without a cast [-Werror=int-conversion]
 #define NULL ((void *)0)
              ^
../common/rtld.c:505:53: note: in expansion of macro 'NULL'
       MSG_ORIG(MSG_RTMAP_STR), addr, DCMD_ADDRSPEC, NULL, NULL);
                                                     ^~~~
In file included from ../common/rtld.c:29:0:
/code/illumos-gate/proto/root_i386/usr/include/sys/mdb_modapi.h:196:12: note: expected 'int' but argument is of type 'void *'
 extern int mdb_call_dcmd(const char *, uintptr_t,
            ^~~~~~~~~~~~~
../common/rtld.c: In function 'walk_rtmap_init':
../common/rtld.c:682:21: error: comparison between pointer and integer [-Werror]
  if (wsp->walk_addr == NULL) {
                     ^~
../common/rtld.c: In function 'walk_rtmap_step':
../common/rtld.c:695:21: error: comparison between pointer and integer [-Werror]
  if (wsp->walk_addr == NULL)
                     ^~

In file included from /code/illumos-gate/proto/root_i386/usr/include/iso/time_iso.h:49:0,
                 from /code/illumos-gate/proto/root_i386/usr/include/time.h:40,
                 from /code/illumos-gate/proto/root_i386/usr/include/sys/time.h:462,
                 from /code/illumos-gate/proto/root_i386/usr/include/sys/select.h:53,
                 from /code/illumos-gate/proto/root_i386/usr/include/sys/types.h:640,
                 from ../common/cap.c:26:
../common/cap.c: In function 'cap_check_lmp_init':
/code/illumos-gate/proto/root_i386/usr/include/sys/null.h:32:14: error: passing argument 3 of 'pnavl_recorded' makes integer from pointer without a cast [-Werror=int-conversion]
 #define NULL ((void *)0)
              ^
../common/cap.c:365:54: note: in expansion of macro 'NULL'
 #define HWAVL_RECORDED(n) pnavl_recorded(&capavl, n, NULL, NULL)
                                                      ^~~~
../common/cap.c:393:17: note: in expansion of macro 'HWAVL_RECORDED'
   if ((file && (HWAVL_RECORDED(file) != 0)) ||
                 ^~~~~~~~~~~~~~
In file included from ../common/cap.c:36:0:
../common/_rtld.h:751:13: note: expected 'uint_t {aka unsigned int}' but argument is of type 'void *'
 extern int  pnavl_recorded(avl_tree_t **, const char *, uint_t,
             ^~~~~~~~~~~~~~
In file included from /code/illumos-gate/proto/root_i386/usr/include/iso/time_iso.h:49:0,
                 from /code/illumos-gate/proto/root_i386/usr/include/time.h:40,
                 from /code/illumos-gate/proto/root_i386/usr/include/sys/time.h:462,
                 from /code/illumos-gate/proto/root_i386/usr/include/sys/select.h:53,
                 from /code/illumos-gate/proto/root_i386/usr/include/sys/types.h:640,
                 from ../common/cap.c:26:
/code/illumos-gate/proto/root_i386/usr/include/sys/null.h:32:14: error: passing argument 3 of 'pnavl_recorded' makes integer from pointer without a cast [-Werror=int-conversion]
 #define NULL ((void *)0)
              ^
../common/cap.c:365:54: note: in expansion of macro 'NULL'
 #define HWAVL_RECORDED(n) pnavl_recorded(&capavl, n, NULL, NULL)
                                                      ^~~~
../common/cap.c:394:8: note: in expansion of macro 'HWAVL_RECORDED'
       (HWAVL_RECORDED(NAME(lmp)) != 0) ||
        ^~~~~~~~~~~~~~
In file included from ../common/cap.c:36:0:
../common/_rtld.h:751:13: note: expected 'uint_t {aka unsigned int}' but argument is of type 'void *'
 extern int  pnavl_recorded(avl_tree_t **, const char *, uint_t,
             ^~~~~~~~~~~~~~
In file included from /code/illumos-gate/proto/root_i386/usr/include/iso/time_iso.h:49:0,
                 from /code/illumos-gate/proto/root_i386/usr/include/time.h:40,
                 from /code/illumos-gate/proto/root_i386/usr/include/sys/time.h:462,
                 from /code/illumos-gate/proto/root_i386/usr/include/sys/select.h:53,
                 from /code/illumos-gate/proto/root_i386/usr/include/sys/types.h:640,
                 from ../common/cap.c:26:
/code/illumos-gate/proto/root_i386/usr/include/sys/null.h:32:14: error: passing argument 3 of 'pnavl_recorded' makes integer from pointer without a cast [-Werror=int-conversion]
 #define NULL ((void *)0)
              ^
../common/cap.c:365:54: note: in expansion of macro 'NULL'
 #define HWAVL_RECORDED(n) pnavl_recorded(&capavl, n, NULL, NULL)
                                                      ^~~~
../common/cap.c:396:8: note: in expansion of macro 'HWAVL_RECORDED'
       (HWAVL_RECORDED(PATHNAME(lmp)) != 0)))
        ^~~~~~~~~~~~~~
In file included from ../common/cap.c:36:0:
../common/_rtld.h:751:13: note: expected 'uint_t {aka unsigned int}' but argument is of type 'void *'
 extern int  pnavl_recorded(avl_tree_t **, const char *, uint_t,
             ^~~~~~~~~~~~~~
In file included from /code/illumos-gate/proto/root_i386/usr/include/iso/time_iso.h:49:0,
                 from /code/illumos-gate/proto/root_i386/usr/include/time.h:40,
                 from /code/illumos-gate/proto/root_i386/usr/include/sys/time.h:462,
                 from /code/illumos-gate/proto/root_i386/usr/include/sys/select.h:53,
                 from /code/illumos-gate/proto/root_i386/usr/include/sys/types.h:640,
                 from ../common/cap.c:26:
/code/illumos-gate/proto/root_i386/usr/include/sys/null.h:32:14: error: passing argument 3 of 'pnavl_recorded' makes integer from pointer without a cast [-Werror=int-conversion]
 #define NULL ((void *)0)
              ^
../common/cap.c:365:54: note: in expansion of macro 'NULL'
 #define HWAVL_RECORDED(n) pnavl_recorded(&capavl, n, NULL, NULL)
                                                      ^~~~
../common/cap.c:404:16: note: in expansion of macro 'HWAVL_RECORDED'
     if ((alt = HWAVL_RECORDED(cp)) != 0)
                ^~~~~~~~~~~~~~
In file included from ../common/cap.c:36:0:
../common/_rtld.h:751:13: note: expected 'uint_t {aka unsigned int}' but argument is of type 'void *'
 extern int  pnavl_recorded(avl_tree_t **, const char *, uint_t,
             ^~~~~~~~~~~~~~
In file included from /code/illumos-gate/proto/root_i386/usr/include/iso/time_iso.h:49:0,
                 from /code/illumos-gate/proto/root_i386/usr/include/time.h:40,
                 from /code/illumos-gate/proto/root_i386/usr/include/sys/time.h:462,
                 from /code/illumos-gate/proto/root_i386/usr/include/sys/select.h:53,
                 from /code/illumos-gate/proto/root_i386/usr/include/sys/types.h:640,
                 from ../common/cap.c:26:
../common/cap.c: In function 'cap_check_fdesc':
/code/illumos-gate/proto/root_i386/usr/include/sys/null.h:32:14: error: passing argument 3 of 'pnavl_recorded' makes integer from pointer without a cast [-Werror=int-conversion]
 #define NULL ((void *)0)
              ^
../common/cap.c:365:54: note: in expansion of macro 'NULL'
 #define HWAVL_RECORDED(n) pnavl_recorded(&capavl, n, NULL, NULL)
                                                      ^~~~
../common/cap.c:466:17: note: in expansion of macro 'HWAVL_RECORDED'
   if ((file && (HWAVL_RECORDED(file) != 0)) ||
                 ^~~~~~~~~~~~~~
In file included from ../common/cap.c:36:0:
../common/_rtld.h:751:13: note: expected 'uint_t {aka unsigned int}' but argument is of type 'void *'
 extern int  pnavl_recorded(avl_tree_t **, const char *, uint_t,
             ^~~~~~~~~~~~~~
In file included from /code/illumos-gate/proto/root_i386/usr/include/iso/time_iso.h:49:0,
                 from /code/illumos-gate/proto/root_i386/usr/include/time.h:40,
                 from /code/illumos-gate/proto/root_i386/usr/include/sys/time.h:462,
                 from /code/illumos-gate/proto/root_i386/usr/include/sys/select.h:53,
                 from /code/illumos-gate/proto/root_i386/usr/include/sys/types.h:640,
                 from ../common/cap.c:26:
/code/illumos-gate/proto/root_i386/usr/include/sys/null.h:32:14: error: passing argument 3 of 'pnavl_recorded' makes integer from pointer without a cast [-Werror=int-conversion]
 #define NULL ((void *)0)
              ^
../common/cap.c:365:54: note: in expansion of macro 'NULL'
 #define HWAVL_RECORDED(n) pnavl_recorded(&capavl, n, NULL, NULL)
                                                      ^~~~
../common/cap.c:467:26: note: in expansion of macro 'HWAVL_RECORDED'
       (fdp->fd_oname && (HWAVL_RECORDED(fdp->fd_oname) != 0)) ||
                          ^~~~~~~~~~~~~~
In file included from ../common/cap.c:36:0:
../common/_rtld.h:751:13: note: expected 'uint_t {aka unsigned int}' but argument is of type 'void *'
 extern int  pnavl_recorded(avl_tree_t **, const char *, uint_t,
             ^~~~~~~~~~~~~~
In file included from /code/illumos-gate/proto/root_i386/usr/include/iso/time_iso.h:49:0,
                 from /code/illumos-gate/proto/root_i386/usr/include/time.h:40,
                 from /code/illumos-gate/proto/root_i386/usr/include/sys/time.h:462,
                 from /code/illumos-gate/proto/root_i386/usr/include/sys/select.h:53,
                 from /code/illumos-gate/proto/root_i386/usr/include/sys/types.h:640,
                 from ../common/cap.c:26:
/code/illumos-gate/proto/root_i386/usr/include/sys/null.h:32:14: error: passing argument 3 of 'pnavl_recorded' makes integer from pointer without a cast [-Werror=int-conversion]
 #define NULL ((void *)0)
              ^
../common/cap.c:365:54: note: in expansion of macro 'NULL'
 #define HWAVL_RECORDED(n) pnavl_recorded(&capavl, n, NULL, NULL)
                                                      ^~~~
../common/cap.c:468:26: note: in expansion of macro 'HWAVL_RECORDED'
       (fdp->fd_nname && (HWAVL_RECORDED(fdp->fd_nname) != 0)) ||
                          ^~~~~~~~~~~~~~
In file included from ../common/cap.c:36:0:
../common/_rtld.h:751:13: note: expected 'uint_t {aka unsigned int}' but argument is of type 'void *'
 extern int  pnavl_recorded(avl_tree_t **, const char *, uint_t,
             ^~~~~~~~~~~~~~
In file included from /code/illumos-gate/proto/root_i386/usr/include/iso/time_iso.h:49:0,
                 from /code/illumos-gate/proto/root_i386/usr/include/time.h:40,
                 from /code/illumos-gate/proto/root_i386/usr/include/sys/time.h:462,
                 from /code/illumos-gate/proto/root_i386/usr/include/sys/select.h:53,
                 from /code/illumos-gate/proto/root_i386/usr/include/sys/types.h:640,
                 from ../common/cap.c:26:
/code/illumos-gate/proto/root_i386/usr/include/sys/null.h:32:14: error: passing argument 3 of 'pnavl_recorded' makes integer from pointer without a cast [-Werror=int-conversion]
 #define NULL ((void *)0)
              ^
../common/cap.c:365:54: note: in expansion of macro 'NULL'
 #define HWAVL_RECORDED(n) pnavl_recorded(&capavl, n, NULL, NULL)
                                                      ^~~~
../common/cap.c:470:8: note: in expansion of macro 'HWAVL_RECORDED'
       (HWAVL_RECORDED(fdp->fd_pname) != 0)))
        ^~~~~~~~~~~~~~
In file included from ../common/cap.c:36:0:
../common/_rtld.h:751:13: note: expected 'uint_t {aka unsigned int}' but argument is of type 'void *'
 extern int  pnavl_recorded(avl_tree_t **, const char *, uint_t,
             ^~~~~~~~~~~~~~

../common/external.c: In function 'get_lcinterface':
../common/external.c:373:42: error: comparison between pointer and integer [-Werror]
       lcp[CI_TLS_STATMOD].lc_un.lc_func) == NULL) {
                                          ^~

../common/config_elf.c: In function 'elf_config_validate':
../common/config_elf.c:119:23: error: comparison between pointer and integer [-Werror]
   if (filetbl->cf_obj == NULL)
                       ^~
../common/config_elf.c: In function 'elf_config':
../common/config_elf.c:335:53: error: comparison between pointer and integer [-Werror]
       (LA_SER_DEFAULT | LA_SER_CONFIG), PD_TKN_CAP) != NULL)
                                                     ^~
../common/config_elf.c:353:52: error: comparison between pointer and integer [-Werror]
       (LA_SER_SECURE | LA_SER_CONFIG), PD_TKN_CAP) != NULL)
                                                    ^~

In file included from /code/illumos-gate/proto/root_i386/usr/include/iso/time_iso.h:49:0,
                 from /code/illumos-gate/proto/root_i386/usr/include/time.h:40,
                 from /code/illumos-gate/proto/root_i386/usr/include/sys/time.h:462,
                 from /code/illumos-gate/proto/root_i386/usr/include/sys/select.h:53,
                 from /code/illumos-gate/proto/root_i386/usr/include/sys/types.h:640,
                 from /code/illumos-gate/proto/root_i386/usr/include/sys/mman.h:54,
                 from ../common/object.c:30:
../common/object.c: In function 'elf_obj_fini':
/code/illumos-gate/proto/root_i386/usr/include/sys/null.h:32:14: error: passing argument 3 of 'pnavl_recorded' makes integer from pointer without a cast [-Werror=int-conversion]
 #define NULL ((void *)0)
              ^
../common/object.c:264:45: note: in expansion of macro 'NULL'
  if (pnavl_recorded(&capavl, ofl->ofl_name, NULL, NULL))
                                             ^~~~
In file included from ../common/object.c:38:0:
../common/_rtld.h:751:13: note: expected 'uint_t {aka unsigned int}' but argument is of type 'void *'
 extern int  pnavl_recorded(avl_tree_t **, const char *, uint_t,
             ^~~~~~~~~~~~~~

../common/dlfcns.c: In function 'dlmopen_core':
../common/dlfcns.c:748:64: error: comparison between pointer and integer [-Werror]
  if (LM_FIX_NAME(clmp)(path, clmp, &palp, AL_CNT_NEEDED, orig) == NULL)
                                                                ^~
../common/dlfcns.c:761:36: error: comparison between pointer and integer [-Werror]
  if ((nlmco = create_cntl(lml, 1)) == NULL) {
                                    ^~

../common/elf.c: In function 'elf_lazy_load':
../common/elf.c:425:35: error: comparison between pointer and integer [-Werror]
  if ((lmco = create_cntl(lml, 0)) == NULL) {
                                   ^~
../common/elf.c: In function '_elf_lookup_filtee':
../common/elf.c:927:37: error: comparison between pointer and integer [-Werror]
    if ((lmco = create_cntl(lml, 0)) == NULL)
                                     ^~
../common/elf.c:928:12: error: return makes integer from pointer without a cast [-Werror=int-conversion]
     return (NULL);
            ^
../common/elf.c:1073:38: error: comparison between pointer and integer [-Werror]
     if ((lmco = create_cntl(lml, 0)) == NULL)
                                      ^~
../common/elf.c:1074:13: error: return makes integer from pointer without a cast [-Werror=int-conversion]
      return (NULL);
             ^
../common/elf.c: In function 'elf_new_lmp':
../common/elf.c:1877:25: error: comparison between pointer and integer [-Werror]
     if (dyn->d_un.d_ptr != NULL)
                         ^~
../common/elf.c:1883:25: error: comparison between pointer and integer [-Werror]
     if (dyn->d_un.d_ptr != NULL)
                         ^~
../common/elf.c: In function 'elf_dladdr':
../common/elf.c:2513:21: error: comparison between pointer and integer [-Werror]
  if (SUNWSYMSZ(lmp) == NULL) {
                     ^~
../common/elf.c: In function 'elf_lazy_find_sym':
../common/elf.c:2723:10: error: return makes integer from pointer without a cast [-Werror=int-conversion]
   return (NULL);
          ^
../common/elf.c:2863:51: error: comparison between pointer and integer [-Werror]
    if (aplist_test(&alist, nlmp, AL_CNT_LAZYFIND) == NULL)
                                                   ^~
../common/analyze.c: In function 'find_file':
../common/analyze.c:1495:17: error: comparison between pointer and integer [-Werror]
    if (*strhash == NULL)
                 ^~
../common/analyze.c: In function 'lookup_sym_interpose':
../common/analyze.c:2719:10: error: return makes integer from pointer without a cast [-Werror=int-conversion]
   return (NULL);
          ^
../common/analyze.c: In function '_lookup_sym':
../common/analyze.c:3131:11: error: return makes integer from pointer without a cast [-Werror=int-conversion]
    return (NULL);
           ^

../common/util.c: In function 'create_cntl':
../common/util.c:1326:11: error: return makes integer from pointer without a cast [-Werror=int-conversion]
    return (NULL);
           ^
cc1: all warnings being treated as errors


  • 0
  • 0
  • 1
  • 0
  • 1
Description From Last Updated
andy_js
  1. Ship It!
  2. 
      
seeemef@mac.com
  1. 
      
  2. usr/src/cmd/sgs/rtld/common/elf.c (Diff revision 1)
     
     

    I read "ptr" in the name, so I'm not sure if (uintptr_t)NULL as you've done in other patches is your preference. 0 seems fine to me though.

    1. The thing is that d_ptr is defined as Elf32_Addr/Elf64_Addr, but those types are integers (unsigned long and unsigned long long). Of course, we can not make assumptions based just on that - the uintptr_t itself is also defined as integres... maybe the most correct approach there would be to use (uintptr_t)NULL to preserve the NULL symbol.

  3. usr/src/cmd/sgs/rtld/common/external.c (Diff revision 1)
     
     

    Curious why 0 for the test of lc_func but NULL for the following assignments to lc_func.

    1. because the if expression is (x && y) == 0, where x and y are pointers. which is why cstyle is asking not to use such constructs:)

  4. 
      
tsoome
seeemef@mac.com
  1. ah sorry I misinterpreted

  2. 
      
tsoome
Review request changed

Status: Closed (submitted)

Loading...