10159 libc: cast between incompatible function types

Review Request #1330 — Created Dec. 23, 2018 and submitted

tsoome
illumos-gate
10159
db1b7d8...
general
../port/threads/c11_thr.c: In function 'thrd_create':
../port/threads/c11_thr.c:198:34: error: cast between incompatible function types from 'thrd_start_t' {aka 'int (*)(void *)'} to 'void * (*)(void *)' [-Werror=cast-function-type]
  ret = pthread_create(thr, NULL, (void *(*)(void *))func, arg);
                                  ^
In file included from /code/illumos-gate/usr/src/lib/libc/inc/thr_uberdata.h:40,
                 from ../port/threads/pthread.c:31:
../port/threads/pthread.c: In function 'pthread_once':
/code/illumos-gate/proto/root_i386/usr/include/pthread.h:167:25: error: cast between incompatible function types from 'int (*)(mutex_t *)' {aka 'int (*)(struct _lwp_mutex *)'} to 'void (*)(void *)' [-Werror=cast-function-type]
  __pthread_cleanup_push((_Voidfp)(routine), (void *)(args), \
                         ^
../port/threads/pthread.c:195:4: note: in expansion of macro 'pthread_cleanup_push'
    pthread_cleanup_push(mutex_unlock, &once->mlock);
    ^~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors


  • 0
  • 0
  • 4
  • 0
  • 4
Description From Last Updated
domag02
  1. C-style.
  2. usr/src/lib/libc/port/threads/tls.c (Diff revision 1)
     
     
    Missing blank before the closing braces. " }"
  3. 
      
tsoome
seeemef@mac.com
  1. 
      
  2. usr/src/lib/libc/port/gen/ssignal.c (Diff revision 2)
     
     

    Is intptr_t vs uintptr_t of any significance?

    1. in this case - no, but with arithmetic of course. Here, I suspect, I did miss the u, however - because in user space we use positive values for pointers and negative ones in the kernel.

  3. 
      
tsoome
domag02
  1. Sorry, I forget to mention these c-style issues previously.
  2. usr/src/lib/libc/port/gen/ssignal.c (Diff revision 3)
     
     

    "If one arm of an if-else statement contains braces, all arms should contain braces."

  3. 
      
seeemef@mac.com
  1. Ship It!
  2. 
      
tsoome
tsoome
Review request changed

Status: Closed (submitted)

Loading...