11431 sort: NULL pointer errors

Review Request #2149 — Created July 11, 2019 and submitted

tsoome
illumos-gate
11431
7042080...
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 /code/illumos-gate/proto/root_i386/usr/include/sys/mman.h:54,
                 from ../common/utility.h:36,
                 from ../common/utility.c:29:
../common/utility.c: In function 'wxwrite':
/code/illumos-gate/proto/root_i386/usr/include/sys/null.h:28:14: error: passing argument 1 of 'cxwrite' makes integer from pointer without a cast [-Werror=int-conversion]
 #define NULL ((void *)0)
              ^
../common/utility.c:559:19: note: in expansion of macro 'NULL'
   return (cxwrite(NULL, 0, 1));
                   ^~~~
../common/utility.c:494:1: note: expected 'int' but argument is of type 'void *'
 cxwrite(int fd, char *ptr, size_t nbytes)
 ^~~~~~~
cc1: all warnings being treated as errors


  • 0
  • 0
  • 1
  • 0
  • 1
Description From Last Updated
citrus
  1. 
      
  2. usr/src/cmd/sort/common/utility.c (Diff revision 1)
     
     

    Just weird..

    int
    cxwrite(int fd, char *ptr, size_t nbytes)
    {
        ...
        write(fd, buffer, offset)
    

    I have no idea what the new line should look like.
    The second argument should most likely be NULL rather than 0, but then why 1 byte for the last argument?
    Writing to STDIN makes little sense..

    return (cxwrite(FILENO_STDOUT, NULL, 0)); ? Your guess is as good as mine!

    1. first one should of course be fd and nbytes can be anything. The reason is, wxwrite() is implementing the multibyte version of cxwrite(); cxwrite() does flush the static buffer when called with ptr == NULL, and while flushing, it is ignoring nbytes because it only needs to write internal buffer.

      So the correct call is cxwrite(fd, NULL, 0).

  3. 
      
tsoome
citrus
  1. Ship It!
  2. 
      
tsoome
Review request changed

Status: Closed (submitted)

Loading...