initial reorg sys/null.h for 5218

Review Request #114 — Created Nov. 7, 2015 and submitted

risto3
illumos-gate
5218, 6487, 6563
77f5542...
general
initial reorg sys/null.h for 5218


Loading file attachments...

  • 0
  • 0
  • 13
  • 3
  • 16
Description From Last Updated
jeffpc
  1. 
      
  2. usr/src/uts/common/sys/null.h (Diff revision 1)
     
     

    Is it possible to use the illumos CDDL header here?

  3. 
      
risto3
rm
  1. 
      
  2. usr/src/head/rpcsvc/dbm.h (Diff revision 2)
     
     

    Please make sure a second bug is opened to cover this.

  3. usr/src/uts/common/sys/null.h (Diff revision 2)
     
     

    If this is copyright by someone else, where did it come from originally? Presumably you need to honor their original license.

    1. In the original 5218, the basis came more or less from
      http://src.illumos.org/source/xref/freebsd-head/sys/sys/_null.h
      but also I used NetBSD current as a reference.
      
      Given this intermediate structure of old defs, I propose to simply drop mention of Mr Moolenaar.
  4. usr/src/uts/common/sys/null.h (Diff revision 2)
     
     

    Comment the #endif

    1. Since this file only defines NULL, I wonder if it is crucial to keep the _SYS_NULL_H biz 
      keeping only the #ifndef NULL guard
      
      I'll add in any event /* NULL */ to the #endif
  5. 
      
risto3
risto3
jeffpc
  1. 
      
  2. usr/src/cmd/mdb/common/mdb/mdb_modapi.h (Diff revision 3)
     
     

    Remove reference to NULL

  3. usr/src/head/fmtmsg.h (Diff revision 3)
     
     

    Any reason these are open-coded instead of using ((char *)NULL)?

    1. When I did this, I judged that the file went through contortions to 'sort of' define NULL
      but fmtmsg.c and all the other users of fmtmsg.h I checked which actually use 'NULL'
      seem to include stdio.h so NULL is defined already in the compilation unit.

      richard@omnis:/home/richard/src/illumos-gate/usr/src$ git grep -l fmtmsg\.h\> '*.[ch]*' |xargs grep -wl NULL 
      cmd/devmgmt/cmds/devattr.c
      cmd/devmgmt/cmds/devreserv.c
      cmd/devmgmt/cmds/getdev.c
      cmd/devmgmt/cmds/getdgrp.c
      cmd/devmgmt/cmds/listdgrp.c
      cmd/devmgmt/cmds/putdev.c
      cmd/devmgmt/cmds/putdgrp.c
      cmd/fmtmsg/main.c
      cmd/logins/logins.c
      cmd/setuname/setuname.c
      cmd/users/users.c
      lib/libc/port/gen/fmtmsg.c
      richard@omnis:/home/richard/src/illumos-gate/usr/src$ git grep -l fmtmsg\.h\> '*.[ch]*' |xargs grep -lw NULL |xargs grep -l stdio\.h
      cmd/devmgmt/cmds/devattr.c
      cmd/devmgmt/cmds/devreserv.c
      cmd/devmgmt/cmds/getdev.c
      cmd/devmgmt/cmds/getdgrp.c
      cmd/devmgmt/cmds/listdgrp.c
      cmd/devmgmt/cmds/putdev.c
      cmd/devmgmt/cmds/putdgrp.c
      cmd/fmtmsg/main.c
      cmd/logins/logins.c
      cmd/setuname/setuname.c
      cmd/users/users.c
      lib/libc/port/gen/fmtmsg.c
      

      To me, simplification imposed.

      As to why these contorsions were taken, I presume no assumptions
      were made as to whether the caller included stdio.h or unistd.h or something
      defining NULL, therefore precaution was done to avoid polluting namespace.

    2. That seems silly given that there is no guarantee that certain header won't pull in another header. (At least it is my understanding that it's implementation defined.)

      Regardless, I'm keeping MM_NULLLBL as is if it will speed up getting this committed.

    3. I guess I'm not sure I follow exactly. Do you mean as it was?

      As indicated above, from my research, all gate users of fmtmsg.h pull in 'NULL' from stdio.h

      Myself, I saw absolutely zero added value to defining '_NULL', then 'NULL' sometimes,
      just to define specifically:

      #define MM_NULL     0L
      
      #define MM_NULLLBL  ((char *)_NULL)
      #define MM_NULLSEV  MM_NOSEV
      #define MM_NULLMC   MM_NULL
      #define MM_NULLTXT  ((char *)_NULL)
      #define MM_NULLACT  ((char *)_NULL)
      #define MM_NULLTAG  ((char *)_NULL)
      

      where _NULL could simply be replace by '0' already in this context.

      BTW, perhaps I should mention that that manpage for fmtmsg.h indicates
      The table below indicates the null values and identifiers for
      fmtmsg(3C) arguments. The <fmtmsg.h> header defines the macros in the
      Identifier column, which expand to constant expressions that expand to
      expressions of the type indicated in the Type column:

      'NULL', itself, is not in this list, so there is no contract specifying that 'NULL'
      needs be defined in fmtmsg.h.

      Finally, I just happended to notice as well that http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/fmtmsg.h.html
      shows that my proposed definition is more or less what is defined by POSIX (abeit with extra parentheses that
      I guess I could to toss if need be).

    4. Oh! I didn't realize that MM_NULL* were part of the interface. I saw that you filed #6563.

  4. 
      
risto3
risto3
rm
  1. 
      
  2. usr/src/cmd/mdb/common/mdb/mdb_modapi.h (Diff revision 5)
     
     

    We still are trying to make sure that NULL has its standard definition by means of including <sys/null.h>. Probably worth updating the comment to add something like, 'We make sure that module writers get NULL by including <sys/null.h>'.

  3. usr/src/cmd/sh/pwd.c (Diff revision 5)
     
     

    If you're fixing the cstyle here, then this brace should open on the line with the while statement.

  4. usr/src/cmd/sh/pwd.c (Diff revision 5)
     
     

    Please use the null character '\0' for terminating here and at +90. Especially given that the file uses '\0' later on at +190/191.

    1. pdir is an unsigned char here, it feels awkward assigning '\0' to what is unsigned.
      Later on, the 'c' variable is a normal signed char.

      I'll swallow and make these all '\0' as you indicate.

  5. usr/src/cmd/sh/pwd.c (Diff revision 5)
     
     

    Same as +88.

  6. usr/src/cmd/sh/pwd.c (Diff revision 5)
     
     

    See +88.

  7. usr/src/cmd/sh/pwd.c (Diff revision 5)
     
     

    See +88.

  8. usr/src/common/util/getoptstr.c (Diff revision 5)
     
     

    With the current NULL definition, don't we now regress this file and change the type that it sees for null?

    1. I guess 'regress' is relative... The whole point of 5218 is to centralise the NULL definition to something
      more 'better'(?)... but in the short run, this first stage is simply centralisation not the final solution.

    2. Agreed - while it's a "regression" as far as the type is concerned, this centralization is the first step to making NULL definition modern everywhere.

    3. Given that we're wsdiffing relatively cleanly, I'm not terribly worried about this anymore.

  9. usr/src/head/rpcsvc/dbm.h (Diff revision 5)
     
     

    What impact doest his have on consumers who previously saw this as a pointer? Does this wsdiff cleanly?

    1. I haven't noticed any "fallout", if that is the question. I have not run wsdiff

    2. Given that we're wsdiffing relatively cleanly, I'm not terribly worried about this anymore.

  10. usr/src/ucbhead/sys/param.h (Diff revision 5)
     
     

    If someone is using the ucb headers where does the definition for NULL now come from?

    1. I was going to say 'unistd.h, already included in this same file'
      Thanks for pointing this one out, which is in a totally different set of includes.

      I notice all of ucbcmd use stdio.h in ucbhead which does defines NULL, but in ucblib
      there is getwd.c that uses NULL but only references unistd.h which would normally have
      NULL defined, but in ucbhead doesn't.

      If there is no opposition, I simply added sys/null.h to ucbhead/unistd.h and corrected
      the NULL definitions by including instead sys/null.h in ucbhead/stdio.h and ucbhead/dbm.h

  11. 
      
risto3
jeffpc
  1. 
      
    1. Weird...I think rb messed up a bit. LGTM.

  2. 
      
risto3
risto3
jeffpc
  1. Ship It!
  2. 
      
risto3
risto3
risto3
risto3
jeffpc
  1. Ship It!
  2. 
      
rm
  1. Otherwise I'm fairly happy with this at this point. Thanks for going through and getting the wsdiff results together.

  2. usr/src/uts/common/sys/null.h (Diff revision 7)
     
     

    Please remove the commented out _ILP32X before this goes back.

  3. 
      
risto3
Review request changed

Status: Closed (submitted)

Change Summary:

commit 4870e0a7381ec2ec57437062574e6ddc3dd48d7f

Loading...