Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uh, get some more numbers #899

Merged
merged 18 commits into from
Jul 2, 2024

Conversation

alejandro-colomar
Copy link
Collaborator

@alejandro-colomar alejandro-colomar commented Jan 11, 2024


v3 v3 changes:
  • Rebase
$ git range-diff gh/strtoll..gh/getuh strtoll..getuh 
 1:  806f0ff5 =  1:  81c8665d lib/getdef.c: getdef_num(): Simplify, by calling a2si() instead of str2sl()
 2:  f0181f03 =  2:  edff0c98 lib/getdef.c: getdef_unum(): Fix wrong limit check
 3:  6d9d10eb =  3:  fd6cfab8 lib/getdef.c: getdef_long(): Simplify, by calling a2sl() instead of str2sl()
 4:  f4692dc4 =  4:  435aa712 lib/limits.c: set_prio(): Simplify, by calling str2si() instead of str2sl()
 5:  36614d26 =  5:  e4b220b9 lib/limits.c: set_umask(): Simplify, by calling str2i(mode_t, ) instead of str2ul()
 6:  b9dcbb2b =  6:  14c14376 lib/limits.c: setup_limits(): Simplify, by calling a2si() instead of str2sl()
 7:  9df29b9f =  7:  1e642aef lib/limits.c: setup_limits(): Simplify, by calling str2si() instead of str2sl()
 8:  d0f99086 =  8:  c214e9fd lib/limits.c: setup_limits(): Simplify, by calling str2i(mode_t, ) instead of str2ul()
 9:  e143fb48 =  9:  bf67cb06 lib/sgetspent.c: sgetspent(): Simplify, by calling a2sl() instead of str2sl()
10:  402bec05 = 10:  9d802247 lib/shadow.c: my_sgetspent(): Merge 'else {if}' into 'else if'
11:  a88d11a7 = 11:  9ba02c4b lib/shadow.c: my_sgetspent(): Remove dead code
12:  2af1a7bf = 12:  047becc1 lib/shadow.c: my_sgetspent(): Simplify error handling
13:  aff746c6 = 13:  486488d9 src/check_subid_range.c: Call get_uid() instead of str2sl()
14:  dbe51a22 = 14:  49058180 src/useradd.c: Simplify, by calling a2sl() instead of str2sl()
15:  5359d519 = 15:  364e750b src/passwd.c: Simplify, by calling a2sl() instead of str2sl()
16:  321774db = 16:  6e4e8d11 src/usermod.c: Simplify, by calling a2sl() instead of str2sl()
17:  48461308 = 17:  eaa538b6 src/faillog.c: Simplify, by calling str2sh() instead of str2sl()
18:  38704923 = 18:  395b5cdd src/chage.c: Simplify, by calling a2sl() instead of str2sl()
v4 v4 changes:
  • Rebase
$ git range-diff 81c8665d^..gh/getuh strtoll..getuh 
 1:  81c8665d =  1:  3b304bae lib/getdef.c: getdef_num(): Simplify, by calling a2si() instead of str2sl()
 2:  edff0c98 =  2:  ff6f6f54 lib/getdef.c: getdef_unum(): Fix wrong limit check
 3:  fd6cfab8 =  3:  943653e5 lib/getdef.c: getdef_long(): Simplify, by calling a2sl() instead of str2sl()
 4:  435aa712 =  4:  a72137c8 lib/limits.c: set_prio(): Simplify, by calling str2si() instead of str2sl()
 5:  e4b220b9 =  5:  33bd3e2d lib/limits.c: set_umask(): Simplify, by calling str2i(mode_t, ) instead of str2ul()
 6:  14c14376 =  6:  8fc11068 lib/limits.c: setup_limits(): Simplify, by calling a2si() instead of str2sl()
 7:  1e642aef =  7:  44e1c015 lib/limits.c: setup_limits(): Simplify, by calling str2si() instead of str2sl()
 8:  c214e9fd =  8:  215349f5 lib/limits.c: setup_limits(): Simplify, by calling str2i(mode_t, ) instead of str2ul()
 9:  bf67cb06 =  9:  f0b9183c lib/sgetspent.c: sgetspent(): Simplify, by calling a2sl() instead of str2sl()
10:  9d802247 = 10:  694cc6b6 lib/shadow.c: my_sgetspent(): Merge 'else {if}' into 'else if'
11:  9ba02c4b = 11:  903b7549 lib/shadow.c: my_sgetspent(): Remove dead code
12:  047becc1 = 12:  7add9a04 lib/shadow.c: my_sgetspent(): Simplify error handling
13:  486488d9 = 13:  5375dd9a src/check_subid_range.c: Call get_uid() instead of str2sl()
14:  49058180 = 14:  08995a95 src/useradd.c: Simplify, by calling a2sl() instead of str2sl()
15:  364e750b = 15:  26ee8c71 src/passwd.c: Simplify, by calling a2sl() instead of str2sl()
16:  6e4e8d11 = 16:  28f4241e src/usermod.c: Simplify, by calling a2sl() instead of str2sl()
17:  eaa538b6 = 17:  3633d2fb src/faillog.c: Simplify, by calling str2sh() instead of str2sl()
18:  395b5cdd = 18:  8a475e05 src/chage.c: Simplify, by calling a2sl() instead of str2sl()
v4b
  • Rebase
$ git range-diff gh/strtoll..gh/getuh strtoll..getuh 
 1:  3b304bae =  1:  41f0c592 lib/getdef.c: getdef_num(): Simplify, by calling a2si() instead of str2sl()
 2:  ff6f6f54 =  2:  ada34659 lib/getdef.c: getdef_unum(): Fix wrong limit check
 3:  943653e5 =  3:  f78721ae lib/getdef.c: getdef_long(): Simplify, by calling a2sl() instead of str2sl()
 4:  a72137c8 =  4:  7cc883a5 lib/limits.c: set_prio(): Simplify, by calling str2si() instead of str2sl()
 5:  33bd3e2d =  5:  75cd2c74 lib/limits.c: set_umask(): Simplify, by calling str2i(mode_t, ) instead of str2ul()
 6:  8fc11068 =  6:  4c067739 lib/limits.c: setup_limits(): Simplify, by calling a2si() instead of str2sl()
 7:  44e1c015 =  7:  58392f10 lib/limits.c: setup_limits(): Simplify, by calling str2si() instead of str2sl()
 8:  215349f5 =  8:  4f0ec8bd lib/limits.c: setup_limits(): Simplify, by calling str2i(mode_t, ) instead of str2ul()
 9:  f0b9183c =  9:  a3d361c6 lib/sgetspent.c: sgetspent(): Simplify, by calling a2sl() instead of str2sl()
10:  694cc6b6 = 10:  570dfeff lib/shadow.c: my_sgetspent(): Merge 'else {if}' into 'else if'
11:  903b7549 = 11:  4ef75e09 lib/shadow.c: my_sgetspent(): Remove dead code
12:  7add9a04 = 12:  a03822a9 lib/shadow.c: my_sgetspent(): Simplify error handling
13:  5375dd9a = 13:  210d3ea9 src/check_subid_range.c: Call get_uid() instead of str2sl()
14:  08995a95 = 14:  ad92731f src/useradd.c: Simplify, by calling a2sl() instead of str2sl()
15:  26ee8c71 = 15:  0ffdc740 src/passwd.c: Simplify, by calling a2sl() instead of str2sl()
16:  28f4241e = 16:  72654b15 src/usermod.c: Simplify, by calling a2sl() instead of str2sl()
17:  3633d2fb = 17:  1746843d src/faillog.c: Simplify, by calling str2sh() instead of str2sl()
18:  8a475e05 = 18:  ce4dbcad src/chage.c: Simplify, by calling a2sl() instead of str2sl()
v4c
  • Rebase
$ git range-diff gh/strtoll..gh/getuh strtoll..getuh 
 1:  41f0c592 =  1:  451d07a8 lib/getdef.c: getdef_num(): Simplify, by calling a2si() instead of str2sl()
 2:  ada34659 =  2:  6dee8116 lib/getdef.c: getdef_unum(): Fix wrong limit check
 3:  f78721ae =  3:  49c44716 lib/getdef.c: getdef_long(): Simplify, by calling a2sl() instead of str2sl()
 4:  7cc883a5 =  4:  cac5f748 lib/limits.c: set_prio(): Simplify, by calling str2si() instead of str2sl()
 5:  75cd2c74 =  5:  d5ab3b8a lib/limits.c: set_umask(): Simplify, by calling str2i(mode_t, ) instead of str2ul()
 6:  4c067739 =  6:  4e89e524 lib/limits.c: setup_limits(): Simplify, by calling a2si() instead of str2sl()
 7:  58392f10 =  7:  426ac24e lib/limits.c: setup_limits(): Simplify, by calling str2si() instead of str2sl()
 8:  4f0ec8bd =  8:  2ef41f0d lib/limits.c: setup_limits(): Simplify, by calling str2i(mode_t, ) instead of str2ul()
 9:  a3d361c6 =  9:  2b25ce91 lib/sgetspent.c: sgetspent(): Simplify, by calling a2sl() instead of str2sl()
10:  570dfeff = 10:  bca0f25c lib/shadow.c: my_sgetspent(): Merge 'else {if}' into 'else if'
11:  4ef75e09 = 11:  482ce215 lib/shadow.c: my_sgetspent(): Remove dead code
12:  a03822a9 = 12:  f3dc9755 lib/shadow.c: my_sgetspent(): Simplify error handling
13:  210d3ea9 = 13:  68ee8b54 src/check_subid_range.c: Call get_uid() instead of str2sl()
14:  ad92731f = 14:  e6cf1be0 src/useradd.c: Simplify, by calling a2sl() instead of str2sl()
15:  0ffdc740 = 15:  dc887b5f src/passwd.c: Simplify, by calling a2sl() instead of str2sl()
16:  72654b15 = 16:  2f08f7e4 src/usermod.c: Simplify, by calling a2sl() instead of str2sl()
17:  1746843d = 17:  2fb41cd8 src/faillog.c: Simplify, by calling str2sh() instead of str2sl()
18:  ce4dbcad = 18:  07497fbf src/chage.c: Simplify, by calling a2sl() instead of str2sl()
v4d
  • Rebase
$ git range-diff gh/strtoll..gh/getuh strtoll..getuh 
 1:  451d07a8 =  1:  b6dd34d7 lib/getdef.c: getdef_num(): Simplify, by calling a2si() instead of str2sl()
 2:  6dee8116 =  2:  e156e34c lib/getdef.c: getdef_unum(): Fix wrong limit check
 3:  49c44716 =  3:  954c403a lib/getdef.c: getdef_long(): Simplify, by calling a2sl() instead of str2sl()
 4:  cac5f748 =  4:  ecefbdb0 lib/limits.c: set_prio(): Simplify, by calling str2si() instead of str2sl()
 5:  d5ab3b8a =  5:  c3a07d1d lib/limits.c: set_umask(): Simplify, by calling str2i(mode_t, ) instead of str2ul()
 6:  4e89e524 =  6:  b1fdb943 lib/limits.c: setup_limits(): Simplify, by calling a2si() instead of str2sl()
 7:  426ac24e =  7:  c6f18eb5 lib/limits.c: setup_limits(): Simplify, by calling str2si() instead of str2sl()
 8:  2ef41f0d =  8:  da7f4e92 lib/limits.c: setup_limits(): Simplify, by calling str2i(mode_t, ) instead of str2ul()
 9:  2b25ce91 =  9:  7b70657e lib/sgetspent.c: sgetspent(): Simplify, by calling a2sl() instead of str2sl()
10:  bca0f25c = 10:  cc56e9b2 lib/shadow.c: my_sgetspent(): Merge 'else {if}' into 'else if'
11:  482ce215 = 11:  4eefc753 lib/shadow.c: my_sgetspent(): Remove dead code
12:  f3dc9755 = 12:  2082f0a1 lib/shadow.c: my_sgetspent(): Simplify error handling
13:  68ee8b54 = 13:  5bcad664 src/check_subid_range.c: Call get_uid() instead of str2sl()
14:  e6cf1be0 = 14:  3761dfb9 src/useradd.c: Simplify, by calling a2sl() instead of str2sl()
15:  dc887b5f = 15:  ffc14251 src/passwd.c: Simplify, by calling a2sl() instead of str2sl()
16:  2f08f7e4 = 16:  2bf7b0a3 src/usermod.c: Simplify, by calling a2sl() instead of str2sl()
17:  2fb41cd8 = 17:  d59a7d1d src/faillog.c: Simplify, by calling str2sh() instead of str2sl()
18:  07497fbf = 18:  5111c23c src/chage.c: Simplify, by calling a2sl() instead of str2sl()
v4e
  • Rebase
$ git range-diff b6dd34d7^..gh/getuh shadow/master..getuh 
 1:  b6dd34d7 =  1:  06e74c19 lib/getdef.c: getdef_num(): Simplify, by calling a2si() instead of str2sl()
 2:  e156e34c =  2:  4677ff18 lib/getdef.c: getdef_unum(): Fix wrong limit check
 3:  954c403a =  3:  d0d9b77f lib/getdef.c: getdef_long(): Simplify, by calling a2sl() instead of str2sl()
 4:  ecefbdb0 =  4:  6373a23b lib/limits.c: set_prio(): Simplify, by calling str2si() instead of str2sl()
 5:  c3a07d1d =  5:  075528ff lib/limits.c: set_umask(): Simplify, by calling str2i(mode_t, ) instead of str2ul()
 6:  b1fdb943 =  6:  936b9e63 lib/limits.c: setup_limits(): Simplify, by calling a2si() instead of str2sl()
 7:  c6f18eb5 =  7:  97bdf04a lib/limits.c: setup_limits(): Simplify, by calling str2si() instead of str2sl()
 8:  da7f4e92 =  8:  993b873b lib/limits.c: setup_limits(): Simplify, by calling str2i(mode_t, ) instead of str2ul()
 9:  7b70657e =  9:  c6f841b3 lib/sgetspent.c: sgetspent(): Simplify, by calling a2sl() instead of str2sl()
10:  cc56e9b2 = 10:  8e63fe8e lib/shadow.c: my_sgetspent(): Merge 'else {if}' into 'else if'
11:  4eefc753 = 11:  9b5c844d lib/shadow.c: my_sgetspent(): Remove dead code
12:  2082f0a1 = 12:  0f0e2146 lib/shadow.c: my_sgetspent(): Simplify error handling
13:  5bcad664 = 13:  30e7e757 src/check_subid_range.c: Call get_uid() instead of str2sl()
14:  3761dfb9 = 14:  164d3ded src/useradd.c: Simplify, by calling a2sl() instead of str2sl()
15:  ffc14251 = 15:  24beb14a src/passwd.c: Simplify, by calling a2sl() instead of str2sl()
16:  2bf7b0a3 = 16:  c7ca65b4 src/usermod.c: Simplify, by calling a2sl() instead of str2sl()
17:  d59a7d1d = 17:  02d810c5 src/faillog.c: Simplify, by calling str2sh() instead of str2sl()
18:  5111c23c = 18:  5a6e763c src/chage.c: Simplify, by calling a2sl() instead of str2sl()
v5
  • Use get_[ug]id() in a few more places.
$ git range-diff shadow/master gh/getuh getuh 
 1:  06e74c19 =  1:  06e74c19 lib/getdef.c: getdef_num(): Simplify, by calling a2si() instead of str2sl()
 2:  4677ff18 =  2:  4677ff18 lib/getdef.c: getdef_unum(): Fix wrong limit check
 3:  d0d9b77f =  3:  d0d9b77f lib/getdef.c: getdef_long(): Simplify, by calling a2sl() instead of str2sl()
 4:  6373a23b =  4:  6373a23b lib/limits.c: set_prio(): Simplify, by calling str2si() instead of str2sl()
 5:  075528ff =  5:  075528ff lib/limits.c: set_umask(): Simplify, by calling str2i(mode_t, ) instead of str2ul()
 6:  936b9e63 =  6:  936b9e63 lib/limits.c: setup_limits(): Simplify, by calling a2si() instead of str2sl()
 7:  97bdf04a =  7:  97bdf04a lib/limits.c: setup_limits(): Simplify, by calling str2si() instead of str2sl()
 8:  993b873b =  8:  993b873b lib/limits.c: setup_limits(): Simplify, by calling str2i(mode_t, ) instead of str2ul()
 9:  c6f841b3 =  9:  c6f841b3 lib/sgetspent.c: sgetspent(): Simplify, by calling a2sl() instead of str2sl()
10:  8e63fe8e = 10:  8e63fe8e lib/shadow.c: my_sgetspent(): Merge 'else {if}' into 'else if'
11:  9b5c844d = 11:  9b5c844d lib/shadow.c: my_sgetspent(): Remove dead code
12:  0f0e2146 = 12:  0f0e2146 lib/shadow.c: my_sgetspent(): Simplify error handling
13:  30e7e757 ! 13:  e5a1defd src/check_subid_range.c: Call get_uid() instead of str2sl()
    @@ Metadata
     Author: Alejandro Colomar <alx@kernel.org>
     
      ## Commit message ##
    -    src/check_subid_range.c: Call get_uid() instead of str2sl()
    -
    -    This value represents a uid.
    +    src/: Use get_[ug]id() where appropriate
     
         Signed-off-by: Alejandro Colomar <alx@kernel.org>
     
    @@ src/check_subid_range.c: int main(int argc, char **argv)
                exit(1);
        if (str2ul(&count, argv[4]) == -1)
                exit(1);
    +
    + ## src/get_subid_owners.c ##
    +@@
    + 
    + #include <stdio.h>
    + 
    +-#include "atoi/str2i.h"
    ++#include "atoi/getnum.h"
    + #include "subid.h"
    + #include "stdlib.h"
    + #include "prototypes.h"
    +@@ src/get_subid_owners.c: int main(int argc, char *argv[])
    +           usage();
    +   }
    +   if (argc == 3 && strcmp(argv[1], "-g") == 0) {
    +-          str2i(uid_t, &u, argv[2]);
    ++          get_uid(argv[2], &u);
    +           n = subid_get_gid_owners(u, &uids);
    +   } else if (argc == 2 && strcmp(argv[1], "-h") == 0) {
    +           usage();
    +   } else {
    +-          str2i(uid_t, &u, argv[1]);
    ++          get_gid(argv[1], &u);
    +           n = subid_get_uid_owners(u, &uids);
    +   }
    +   if (n < 0) {
14:  164d3ded = 14:  299c84a1 src/useradd.c: Simplify, by calling a2sl() instead of str2sl()
15:  24beb14a = 15:  781fd1a6 src/passwd.c: Simplify, by calling a2sl() instead of str2sl()
16:  c7ca65b4 = 16:  3d26dc5a src/usermod.c: Simplify, by calling a2sl() instead of str2sl()
17:  02d810c5 = 17:  a49bfd18 src/faillog.c: Simplify, by calling str2sh() instead of str2sl()
18:  5a6e763c = 18:  fb0f3ecb src/chage.c: Simplify, by calling a2sl() instead of str2sl()
v5b
  • Rebase
$ git range-diff master..gh/getuh shadow/master..getuh 
 1:  06e74c19 !  1:  ffca6d40 lib/getdef.c: getdef_num(): Simplify, by calling a2si() instead of str2sl()
    @@ Commit message
     
      ## lib/getdef.c ##
     @@
    + #include <libeconf.h>
      #endif
      
    - #include "alloc.h"
     +#include "atoi/a2i.h"
      #include "atoi/str2i.h"
    + #include "defines.h"
      #include "getdef.h"
    - #include "shadowlog_internal.h"
     @@ lib/getdef.c: bool getdef_bool (const char *item)
       * values are handled.
       */
 2:  4677ff18 =  2:  f568010e lib/getdef.c: getdef_unum(): Fix wrong limit check
 3:  d0d9b77f =  3:  f872fb97 lib/getdef.c: getdef_long(): Simplify, by calling a2sl() instead of str2sl()
 4:  6373a23b =  4:  6ec310ee lib/limits.c: set_prio(): Simplify, by calling str2si() instead of str2sl()
 5:  075528ff =  5:  1654022c lib/limits.c: set_umask(): Simplify, by calling str2i(mode_t, ) instead of str2ul()
 6:  936b9e63 =  6:  b5c15c64 lib/limits.c: setup_limits(): Simplify, by calling a2si() instead of str2sl()
 7:  97bdf04a =  7:  2a14ebf4 lib/limits.c: setup_limits(): Simplify, by calling str2si() instead of str2sl()
 8:  993b873b =  8:  d2315991 lib/limits.c: setup_limits(): Simplify, by calling str2i(mode_t, ) instead of str2ul()
 9:  c6f841b3 =  9:  0b3e6c8b lib/sgetspent.c: sgetspent(): Simplify, by calling a2sl() instead of str2sl()
10:  8e63fe8e = 10:  c29af369 lib/shadow.c: my_sgetspent(): Merge 'else {if}' into 'else if'
11:  9b5c844d = 11:  5f497e9e lib/shadow.c: my_sgetspent(): Remove dead code
12:  0f0e2146 ! 12:  e7dcdb4c lib/shadow.c: my_sgetspent(): Simplify error handling
    @@ Commit message
     
      ## lib/shadow.c ##
     @@
    - #include "defines.h"
    - #include <stdio.h>
    + #include <string.h>
    + #include <sys/types.h>
      
     +#include "atoi/a2i.h"
      #include "atoi/str2i.h"
    - 
    - 
    + #include "defines.h"
    + #include "prototypes.h"
     @@ lib/shadow.c: static struct spwd *my_sgetspent (const char *string)
      
        if (fields[2][0] == '\0')
13:  e5a1defd = 13:  aea35eb6 src/: Use get_[ug]id() where appropriate
14:  299c84a1 ! 14:  1be8cd81 src/useradd.c: Simplify, by calling a2sl() instead of str2sl()
    @@ src/useradd.c
     @@
      #include <unistd.h>
      
    - #include "alloc.h"
    + #include "alloc/x/xmalloc.h"
     -#include "atoi/str2i.h"
     +#include "atoi/a2i.h"
      #include "atoi/getnum.h"
15:  781fd1a6 ! 15:  6a61fefd src/passwd.c: Simplify, by calling a2sl() instead of str2sl()
    @@ Commit message
     
      ## src/passwd.c ##
     @@
    + #include <time.h>
      
      #include "agetpass.h"
    - #include "alloc.h"
     -#include "atoi/str2i.h"
     +#include "atoi/a2i.h"
      #include "defines.h"
16:  3d26dc5a ! 16:  bca3a624 src/usermod.c: Simplify, by calling a2sl() instead of str2sl()
    @@ Commit message
     
      ## src/usermod.c ##
     @@
    - #include "alloc.h"
    + #include "alloc/x/xmalloc.h"
      #include "atoi/a2i.h"
      #include "atoi/getnum.h"
     -#include "atoi/str2i.h"
17:  a49bfd18 = 17:  def0a300 src/faillog.c: Simplify, by calling str2sh() instead of str2sl()
18:  fb0f3ecb ! 18:  6b176d86 src/chage.c: Simplify, by calling a2sl() instead of str2sl()
    @@ Commit message
     
      ## src/chage.c ##
     @@
    + #endif                            /* ACCT_TOOLS_SETUID */
      #include <pwd.h>
      
    - #include "alloc.h"
     -#include "atoi/str2i.h"
     +#include "atoi/a2i.h"
      #include "defines.h"

@alejandro-colomar
Copy link
Collaborator Author

v2 changes:

  • Rebase to master
$ git range-diff --creation-factor=99 gh/strtoll..gh/getuh strtoll..getuh 
 1:  8d7d5b18 =  1:  ca06c536 lib/getdef.c: getdef_num(): Simplify, by calling a2si() instead of str2sl()
 2:  739856c5 =  2:  f39d39b5 lib/getdef.c: getdef_unum(): Fix wrong limit check
 3:  810acd36 =  3:  dc98f63e lib/getdef.c: getdef_long(): Simplify, by calling a2sl() instead of str2sl()
 4:  096eede0 =  4:  c9d86e9e lib/limits.c: set_prio(): Simplify, by calling str2si() instead of str2sl()
 5:  ab2d2fdd =  5:  1ab4608d lib/limits.c: set_umask(): Simplify, by calling str2i(mode_t, ) instead of str2ul()
 6:  63902a40 =  6:  93439f65 lib/limits.c: setup_limits(): Simplify, by calling a2si() instead of str2sl()
 7:  aa66f0cd =  7:  6d1b9361 lib/limits.c: setup_limits(): Simplify, by calling str2si() instead of str2sl()
 8:  b06780b6 =  8:  d79de598 lib/limits.c: setup_limits(): Simplify, by calling str2i(mode_t, ) instead of str2ul()
 9:  ef712a6b !  9:  db9121fe lib/sgetspent.c: sgetspent(): Simplify, by calling a2sl() instead of str2sl()
    @@ Commit message
     
      ## lib/sgetspent.c ##
     @@
    - #include "defines.h"
    - #include <stdio.h>
    + #include <sys/types.h>
    + #include <string.h>
      
     +#include "atoi/a2i.h"
      #include "atoi/str2i.h"
    - 
    - 
    -@@ lib/sgetspent.c: struct spwd *sgetspent (const char *string)
    + #include "prototypes.h"
    + #include "shadowlog_internal.h"
    +@@ lib/sgetspent.c: sgetspent(const char *string)
         * incorrectly formatted number.
         */
      
    @@ lib/sgetspent.c: struct spwd *sgetspent (const char *string)
     -  } else if (   (str2sl(&spwd.sp_lstchg, fields[2]) == -1)
     -             || (spwd.sp_lstchg < 0)) {
     +  else if (a2sl(&spwd.sp_lstchg, fields[2], NULL, 0, 0, LONG_MAX) == -1)
    -           return 0;
    +           return NULL;
     -  }
      
        /*
    @@ lib/sgetspent.c: struct spwd *sgetspent (const char *string)
     -  } else if (   (str2sl(&spwd.sp_min, fields[3]) == -1)
     -             || (spwd.sp_min < 0)) {
     +  else if (a2sl(&spwd.sp_min, fields[3], NULL, 0, 0, LONG_MAX) == -1)
    -           return 0;
    +           return NULL;
     -  }
      
        /*
    @@ lib/sgetspent.c: struct spwd *sgetspent (const char *string)
     -  } else if (   (str2sl(&spwd.sp_max, fields[4]) == -1)
     -             || (spwd.sp_max < 0)) {
     +  else if (a2sl(&spwd.sp_max, fields[4], NULL, 0, 0, LONG_MAX) == -1)
    -           return 0;
    +           return NULL;
     -  }
      
        /*
         * If there are only OFIELDS fields (this is a SVR3.2 /etc/shadow
    -@@ lib/sgetspent.c: struct spwd *sgetspent (const char *string)
    +@@ lib/sgetspent.c: sgetspent(const char *string)
         * Get the number of days of password expiry warning.
         */
      
    @@ lib/sgetspent.c: struct spwd *sgetspent (const char *string)
     -  } else if (   (str2sl(&spwd.sp_warn, fields[5]) == -1)
     -             || (spwd.sp_warn < 0)) {
     +  else if (a2sl(&spwd.sp_warn, fields[5], NULL, 0, 0, LONG_MAX) == -1)
    -           return 0;
    +           return NULL;
     -  }
      
        /*
    @@ lib/sgetspent.c: struct spwd *sgetspent (const char *string)
     -  } else if (   (str2sl(&spwd.sp_inact, fields[6]) == -1)
     -             || (spwd.sp_inact < 0)) {
     +  else if (a2sl(&spwd.sp_inact, fields[6], NULL, 0, 0, LONG_MAX) == -1)
    -           return 0;
    +           return NULL;
     -  }
      
        /*
    @@ lib/sgetspent.c: struct spwd *sgetspent (const char *string)
     -  } else if (   (str2sl(&spwd.sp_expire, fields[7]) == -1)
     -             || (spwd.sp_expire < 0)) {
     +  else if (a2sl(&spwd.sp_expire, fields[7], NULL, 0, 0, LONG_MAX) == -1)
    -           return 0;
    +           return NULL;
     -  }
      
        /*
    @@ lib/sgetspent.c: struct spwd *sgetspent (const char *string)
                spwd.sp_flag = SHADOW_SP_FLAG_UNSET;
     -  } else if (str2ul(&spwd.sp_flag, fields[8]) == -1) {
     +  else if (str2ul(&spwd.sp_flag, fields[8]) == -1)
    -           return 0;
    +           return NULL;
     -  }
      
        return (&spwd);
10:  c6da9e43 ! 10:  b01a0529 lib/shadow.c: my_sgetspent(): Merge 'else {if}' into 'else if'
    @@ Commit message
     
      ## lib/shadow.c ##
     @@ lib/shadow.c: static struct spwd *my_sgetspent (const char *string)
    +    * incorrectly formatted number, unless we are using NIS.
    +    */
      
    -   if (fields[2][0] == '\0') {
    +-  if (fields[2][0] == '\0') {
    ++  if (fields[2][0] == '\0')
                spwd.sp_lstchg = -1;
     -  } else {
    --          if (str2sl(&spwd.sp_lstchg, fields[2]) == -1) {
    -+  } else if (str2sl(&spwd.sp_lstchg, fields[2]) == -1) {
    - #ifdef    USE_NIS
    --                  if (nis_used) {
    --                          spwd.sp_lstchg = -1;
    --                  } else
    -+          if (nis_used) {
    -+                  spwd.sp_lstchg = -1;
    -+          } else
    - #endif
    --                          return 0;
    --          } else if (spwd.sp_lstchg < 0) {
    -+          {
    -                   return 0;
    -           }
    -+  } else if (spwd.sp_lstchg < 0) {
    +-          if (str2sl(&spwd.sp_lstchg, fields[2]) == -1)
    +-                  return 0;
    +-          if (spwd.sp_lstchg < 0)
    +-                  return 0;
    +-  }
    ++  else if (str2sl(&spwd.sp_lstchg, fields[2]) == -1)
    ++          return 0;
    ++  else if (spwd.sp_lstchg < 0)
     +          return 0;
    -   }
      
        /*
    -@@ lib/shadow.c: static struct spwd *my_sgetspent (const char *string)
    +    * Get the minimum period between password changes.
    +    */
      
    -   if (fields[3][0] == '\0') {
    +-  if (fields[3][0] == '\0') {
    ++  if (fields[3][0] == '\0')
                spwd.sp_min = -1;
     -  } else {
    --          if (str2sl(&spwd.sp_min, fields[3]) == -1) {
    -+  } else if (str2sl(&spwd.sp_min, fields[3]) == -1) {
    - #ifdef    USE_NIS
    --                  if (nis_used) {
    --                          spwd.sp_min = -1;
    --                  } else
    -+          if (nis_used) {
    -+                  spwd.sp_min = -1;
    -+          } else
    - #endif
    --                  {
    --                          return 0;
    --                  }
    --          } else if (spwd.sp_min < 0) {
    -+          {
    -                   return 0;
    -           }
    -+  } else if (spwd.sp_min < 0) {
    +-          if (str2sl(&spwd.sp_min, fields[3]) == -1)
    +-                  return 0;
    +-          if (spwd.sp_min < 0)
    +-                  return 0;
    +-  }
    ++  else if (str2sl(&spwd.sp_min, fields[3]) == -1)
    ++          return 0;
    ++  else if (spwd.sp_min < 0)
     +          return 0;
    -   }
      
        /*
    -@@ lib/shadow.c: static struct spwd *my_sgetspent (const char *string)
    +    * Get the maximum number of days a password is valid.
    +    */
      
    -   if (fields[4][0] == '\0') {
    +-  if (fields[4][0] == '\0') {
    ++  if (fields[4][0] == '\0')
                spwd.sp_max = -1;
     -  } else {
    --          if (str2sl(&spwd.sp_max, fields[4]) == -1) {
    -+  } else if (str2sl(&spwd.sp_max, fields[4]) == -1) {
    - #ifdef    USE_NIS
    --                  if (nis_used) {
    --                          spwd.sp_max = -1;
    --                  } else
    -+          if (nis_used) {
    -+                  spwd.sp_max = -1;
    -+          } else
    - #endif
    --                          return 0;
    --          } else if (spwd.sp_max < 0) {
    -+          {
    -                   return 0;
    -           }
    -+  } else if (spwd.sp_max < 0) {
    +-          if (str2sl(&spwd.sp_max, fields[4]) == -1)
    +-                  return 0;
    +-          if (spwd.sp_max < 0)
    +-                  return 0;
    +-  }
    ++  else if (str2sl(&spwd.sp_max, fields[4]) == -1)
    ++          return 0;
    ++  else if (spwd.sp_max < 0)
     +          return 0;
    -   }
      
        /*
    +    * If there are only OFIELDS fields (this is a SVR3.2 /etc/shadow
     @@ lib/shadow.c: static struct spwd *my_sgetspent (const char *string)
    +    * Get the number of days of password expiry warning.
    +    */
      
    -   if (fields[5][0] == '\0') {
    +-  if (fields[5][0] == '\0') {
    ++  if (fields[5][0] == '\0')
                spwd.sp_warn = -1;
     -  } else {
    --          if (str2sl(&spwd.sp_warn, fields[5]) == -1) {
    -+  } else if (str2sl(&spwd.sp_warn, fields[5]) == -1) {
    - #ifdef    USE_NIS
    --                  if (nis_used) {
    --                          spwd.sp_warn = -1;
    --                  } else
    -+          if (nis_used) {
    -+                  spwd.sp_warn = -1;
    -+          } else
    - #endif
    --                  {
    --                          return 0;
    --                  }
    --          } else if (spwd.sp_warn < 0) {
    -+          {
    -                   return 0;
    -           }
    -+  } else if (spwd.sp_warn < 0) {
    +-          if (str2sl(&spwd.sp_warn, fields[5]) == -1)
    +-                  return 0;
    +-          if (spwd.sp_warn < 0)
    +-                  return 0;
    +-  }
    ++  else if (str2sl(&spwd.sp_warn, fields[5]) == -1)
    ++          return 0;
    ++  else if (spwd.sp_warn < 0)
     +          return 0;
    -   }
      
        /*
    -@@ lib/shadow.c: static struct spwd *my_sgetspent (const char *string)
    +    * Get the number of days of inactivity before an account is
    +    * disabled.
    +    */
      
    -   if (fields[6][0] == '\0') {
    +-  if (fields[6][0] == '\0') {
    ++  if (fields[6][0] == '\0')
                spwd.sp_inact = -1;
     -  } else {
    --          if (str2sl(&spwd.sp_inact, fields[6]) == -1) {
    -+  } else if (str2sl(&spwd.sp_inact, fields[6]) == -1) {
    - #ifdef    USE_NIS
    --                  if (nis_used) {
    --                          spwd.sp_inact = -1;
    --                  } else
    -+          if (nis_used) {
    -+                  spwd.sp_inact = -1;
    -+          } else
    - #endif
    --                  {
    --                          return 0;
    --                  }
    --          } else if (spwd.sp_inact < 0) {
    -+          {
    -                   return 0;
    -           }
    -+  } else if (spwd.sp_inact < 0) {
    +-          if (str2sl(&spwd.sp_inact, fields[6]) == -1)
    +-                  return 0;
    +-          if (spwd.sp_inact < 0)
    +-                  return 0;
    +-  }
    ++  else if (str2sl(&spwd.sp_inact, fields[6]) == -1)
    ++          return 0;
    ++  else if (spwd.sp_inact < 0)
     +          return 0;
    -   }
      
        /*
    -@@ lib/shadow.c: static struct spwd *my_sgetspent (const char *string)
    +    * Get the number of days after the epoch before the account is
    +    * set to expire.
    +    */
      
    -   if (fields[7][0] == '\0') {
    +-  if (fields[7][0] == '\0') {
    ++  if (fields[7][0] == '\0')
                spwd.sp_expire = -1;
     -  } else {
    --          if (str2sl(&spwd.sp_expire, fields[7]) == -1) {
    -+  } else if (str2sl(&spwd.sp_expire, fields[7]) == -1) {
    - #ifdef    USE_NIS
    --                  if (nis_used) {
    --                          spwd.sp_expire = -1;
    --                  } else
    -+          if (nis_used) {
    -+                  spwd.sp_expire = -1;
    -+          } else
    - #endif
    --                  {
    --                          return 0;
    --                  }
    --          } else if (spwd.sp_expire < 0) {
    -+          {
    -                   return 0;
    -           }
    -+  } else if (spwd.sp_expire < 0) {
    +-          if (str2sl(&spwd.sp_expire, fields[7]) == -1)
    +-                  return 0;
    +-          if (spwd.sp_expire < 0)
    +-                  return 0;
    +-  }
    ++  else if (str2sl(&spwd.sp_expire, fields[7]) == -1)
    ++          return 0;
    ++  else if (spwd.sp_expire < 0)
     +          return 0;
    -   }
      
        /*
    -@@ lib/shadow.c: static struct spwd *my_sgetspent (const char *string)
    +    * This field is reserved for future use.  But it isn't supposed
    +    * to have anything other than a valid integer in it.
    +    */
      
    -   if (fields[8][0] == '\0') {
    +-  if (fields[8][0] == '\0') {
    ++  if (fields[8][0] == '\0')
                spwd.sp_flag = SHADOW_SP_FLAG_UNSET;
     -  } else {
    --          if (str2ul(&spwd.sp_flag, fields[8]) == -1) {
    -+  } else if (str2ul(&spwd.sp_flag, fields[8]) == -1) {
    - #ifdef    USE_NIS
    --                  if (nis_used) {
    --                          spwd.sp_flag = SHADOW_SP_FLAG_UNSET;
    --                  } else
    -+          if (nis_used) {
    -+                  spwd.sp_flag = SHADOW_SP_FLAG_UNSET;
    -+          } else
    - #endif
    --                  {
    --                          return 0;
    --                  }
    --          } else if (spwd.sp_flag < 0) {
    -+          {
    -                   return 0;
    -           }
    -+  } else if (spwd.sp_flag < 0) {
    +-          if (str2ul(&spwd.sp_flag, fields[8]) == -1)
    +-                  return 0;
    +-          if (spwd.sp_flag < 0)
    +-                  return 0;
    +-  }
    ++  else if (str2ul(&spwd.sp_flag, fields[8]) == -1)
    ++          return 0;
    ++  else if (spwd.sp_flag < 0)
     +          return 0;
    -   }
      
        return (&spwd);
    + }
11:  ba5da730 ! 11:  0e1edd82 lib/shadow.c: my_sgetspent(): Remove dead code
    @@ Commit message
     
      ## lib/shadow.c ##
     @@ lib/shadow.c: static struct spwd *my_sgetspent (const char *string)
    -           {
    -                   return 0;
    -           }
    --  } else if (spwd.sp_flag < 0) {
    +           spwd.sp_flag = SHADOW_SP_FLAG_UNSET;
    +   else if (str2ul(&spwd.sp_flag, fields[8]) == -1)
    +           return 0;
    +-  else if (spwd.sp_flag < 0)
     -          return 0;
    -   }
      
        return (&spwd);
    + }
12:  37aa0119 ! 12:  56f18e94 lib/shadow.c: my_sgetspent(): Fix error handling
    @@ Metadata
     Author: Alejandro Colomar <alx@kernel.org>
     
      ## Commit message ##
    -    lib/shadow.c: my_sgetspent(): Fix error handling
    -
    -    If "negative seven" is not an error if USE_NIS, I don't think "-7"
    -    should be either.
    +    lib/shadow.c: my_sgetspent(): Simplify error handling
     
         Handle negative values as errors from a2sl(), and reuse its
         error-handling code.
     
    -    Fixes: 9a7f5c6b16ef ("* lib/shadow.c: Replace strtol() by getlong(). Also detect more issues in a numerical shadow entry field.")
    -    Link: <https://github.com/shadow-maint/shadow/commit/9a7f5c6b16ef9d1ca8637a3dcb5e27cd1c5dc372>
         Cc: Iker Pedrosa <ipedrosa@redhat.com>
         Cc: "Serge E. Hallyn" <serge@hallyn.com>
         Signed-off-by: Alejandro Colomar <alx@kernel.org>
    @@ lib/shadow.c
      
     @@ lib/shadow.c: static struct spwd *my_sgetspent (const char *string)
      
    -   if (fields[2][0] == '\0') {
    +   if (fields[2][0] == '\0')
                spwd.sp_lstchg = -1;
    --  } else if (str2sl(&spwd.sp_lstchg, fields[2]) == -1) {
    -+  } else if (a2sl(&spwd.sp_lstchg, fields[2], NULL, 0, 0, LONG_MAX) == -1) {
    - #ifdef    USE_NIS
    -           if (nis_used) {
    -                   spwd.sp_lstchg = -1;
    -@@ lib/shadow.c: static struct spwd *my_sgetspent (const char *string)
    -           {
    -                   return 0;
    -           }
    --  } else if (spwd.sp_lstchg < 0) {
    +-  else if (str2sl(&spwd.sp_lstchg, fields[2]) == -1)
     -          return 0;
    -   }
    +-  else if (spwd.sp_lstchg < 0)
    ++  else if (a2sl(&spwd.sp_lstchg, fields[2], NULL, 0, 0, LONG_MAX) == -1)
    +           return 0;
      
        /*
     @@ lib/shadow.c: static struct spwd *my_sgetspent (const char *string)
      
    -   if (fields[3][0] == '\0') {
    +   if (fields[3][0] == '\0')
                spwd.sp_min = -1;
    --  } else if (str2sl(&spwd.sp_min, fields[3]) == -1) {
    -+  } else if (a2sl(&spwd.sp_min, fields[3], NULL, 0, 0, LONG_MAX) == -1) {
    - #ifdef    USE_NIS
    -           if (nis_used) {
    -                   spwd.sp_min = -1;
    -@@ lib/shadow.c: static struct spwd *my_sgetspent (const char *string)
    -           {
    -                   return 0;
    -           }
    --  } else if (spwd.sp_min < 0) {
    +-  else if (str2sl(&spwd.sp_min, fields[3]) == -1)
     -          return 0;
    -   }
    +-  else if (spwd.sp_min < 0)
    ++  else if (a2sl(&spwd.sp_min, fields[3], NULL, 0, 0, LONG_MAX) == -1)
    +           return 0;
      
        /*
     @@ lib/shadow.c: static struct spwd *my_sgetspent (const char *string)
      
    -   if (fields[4][0] == '\0') {
    +   if (fields[4][0] == '\0')
                spwd.sp_max = -1;
    --  } else if (str2sl(&spwd.sp_max, fields[4]) == -1) {
    -+  } else if (a2sl(&spwd.sp_max, fields[4], NULL, 0, 0, LONG_MAX) == -1) {
    - #ifdef    USE_NIS
    -           if (nis_used) {
    -                   spwd.sp_max = -1;
    -@@ lib/shadow.c: static struct spwd *my_sgetspent (const char *string)
    -           {
    -                   return 0;
    -           }
    --  } else if (spwd.sp_max < 0) {
    +-  else if (str2sl(&spwd.sp_max, fields[4]) == -1)
     -          return 0;
    -   }
    +-  else if (spwd.sp_max < 0)
    ++  else if (a2sl(&spwd.sp_max, fields[4], NULL, 0, 0, LONG_MAX) == -1)
    +           return 0;
      
        /*
     @@ lib/shadow.c: static struct spwd *my_sgetspent (const char *string)
      
    -   if (fields[5][0] == '\0') {
    +   if (fields[5][0] == '\0')
                spwd.sp_warn = -1;
    --  } else if (str2sl(&spwd.sp_warn, fields[5]) == -1) {
    -+  } else if (a2sl(&spwd.sp_warn, fields[5], NULL, 0, 0, LONG_MAX) == -1) {
    - #ifdef    USE_NIS
    -           if (nis_used) {
    -                   spwd.sp_warn = -1;
    -@@ lib/shadow.c: static struct spwd *my_sgetspent (const char *string)
    -           {
    -                   return 0;
    -           }
    --  } else if (spwd.sp_warn < 0) {
    +-  else if (str2sl(&spwd.sp_warn, fields[5]) == -1)
     -          return 0;
    -   }
    +-  else if (spwd.sp_warn < 0)
    ++  else if (a2sl(&spwd.sp_warn, fields[5], NULL, 0, 0, LONG_MAX) == -1)
    +           return 0;
      
        /*
     @@ lib/shadow.c: static struct spwd *my_sgetspent (const char *string)
      
    -   if (fields[6][0] == '\0') {
    +   if (fields[6][0] == '\0')
                spwd.sp_inact = -1;
    --  } else if (str2sl(&spwd.sp_inact, fields[6]) == -1) {
    -+  } else if (a2sl(&spwd.sp_inact, fields[6], NULL, 0, 0, LONG_MAX) == -1) {
    - #ifdef    USE_NIS
    -           if (nis_used) {
    -                   spwd.sp_inact = -1;
    -@@ lib/shadow.c: static struct spwd *my_sgetspent (const char *string)
    -           {
    -                   return 0;
    -           }
    --  } else if (spwd.sp_inact < 0) {
    +-  else if (str2sl(&spwd.sp_inact, fields[6]) == -1)
     -          return 0;
    -   }
    +-  else if (spwd.sp_inact < 0)
    ++  else if (a2sl(&spwd.sp_inact, fields[6], NULL, 0, 0, LONG_MAX) == -1)
    +           return 0;
      
        /*
     @@ lib/shadow.c: static struct spwd *my_sgetspent (const char *string)
      
    -   if (fields[7][0] == '\0') {
    +   if (fields[7][0] == '\0')
                spwd.sp_expire = -1;
    --  } else if (str2sl(&spwd.sp_expire, fields[7]) == -1) {
    -+  } else if (a2sl(&spwd.sp_expire, fields[7], NULL, 0, 0, LONG_MAX) == -1) {
    - #ifdef    USE_NIS
    -           if (nis_used) {
    -                   spwd.sp_expire = -1;
    -@@ lib/shadow.c: static struct spwd *my_sgetspent (const char *string)
    -           {
    -                   return 0;
    -           }
    --  } else if (spwd.sp_expire < 0) {
    +-  else if (str2sl(&spwd.sp_expire, fields[7]) == -1)
     -          return 0;
    -   }
    +-  else if (spwd.sp_expire < 0)
    ++  else if (a2sl(&spwd.sp_expire, fields[7], NULL, 0, 0, LONG_MAX) == -1)
    +           return 0;
      
        /*
13:  e9165174 = 13:  9cee75f3 src/check_subid_range.c: Call get_uid() instead of str2sl()
14:  474cb8d6 = 14:  413f764a src/useradd.c: Simplify, by calling a2sl() instead of str2sl()
15:  d3c9e046 = 15:  922ce82f src/passwd.c: Simplify, by calling a2sl() instead of str2sl()
16:  37f2bbee = 16:  e324128d src/usermod.c: Simplify, by calling a2sl() instead of str2sl()
17:  537e5c47 = 17:  7966b682 src/faillog.c: Simplify, by calling str2sh() instead of str2sl()
18:  406269b4 ! 18:  fe0cf332 src/chage.c: Simplify, by calling a2sl() instead of str2sl()
    @@ src/chage.c
      #include "alloc.h"
     -#include "atoi/str2i.h"
     +#include "atoi/a2i.h"
    - #include "prototypes.h"
      #include "defines.h"
      #include "memzero.h"
    + #include "prototypes.h"
     @@ src/chage.c: static int new_fields (void)
      
        SNPRINTF(buf, "%ld", mindays);
    @@ src/chage.c: static int new_fields (void)
                return 0;
     -  }
      
    -   if (-1 == lstchgdate || lstchgdate > LONG_MAX / DAY) {
    -           strcpy (buf, "-1");
    +   if (-1 == lstchgdate || lstchgdate > LONG_MAX / DAY)
    +           strcpy(buf, "-1");
     @@ src/chage.c: static int new_fields (void)
      
        SNPRINTF(buf, "%ld", warndays);
    @@ src/chage.c: static int new_fields (void)
                return 0;
     -  }
      
    -   if (-1 == expdate || LONG_MAX / DAY < expdate) {
    -           strcpy (buf, "-1");
    +   if (-1 == expdate || LONG_MAX / DAY < expdate)
    +           strcpy(buf, "-1");
     @@ src/chage.c: static void process_flags (int argc, char **argv)
                        break;
                case 'I':

@alejandro-colomar
Copy link
Collaborator Author

v2b changes:

  • Rebase on master
$ git range-diff gh/strtoll..gh/getuh strtoll..getuh 
 1:  ca06c536 =  1:  d9ab1ecf lib/getdef.c: getdef_num(): Simplify, by calling a2si() instead of str2sl()
 2:  f39d39b5 =  2:  367fb843 lib/getdef.c: getdef_unum(): Fix wrong limit check
 3:  dc98f63e =  3:  92afbb68 lib/getdef.c: getdef_long(): Simplify, by calling a2sl() instead of str2sl()
 4:  c9d86e9e =  4:  ca682ecc lib/limits.c: set_prio(): Simplify, by calling str2si() instead of str2sl()
 5:  1ab4608d =  5:  05221444 lib/limits.c: set_umask(): Simplify, by calling str2i(mode_t, ) instead of str2ul()
 6:  93439f65 =  6:  2778909f lib/limits.c: setup_limits(): Simplify, by calling a2si() instead of str2sl()
 7:  6d1b9361 =  7:  c7bc89cf lib/limits.c: setup_limits(): Simplify, by calling str2si() instead of str2sl()
 8:  d79de598 =  8:  16ee60e8 lib/limits.c: setup_limits(): Simplify, by calling str2i(mode_t, ) instead of str2ul()
 9:  db9121fe =  9:  25dcaab2 lib/sgetspent.c: sgetspent(): Simplify, by calling a2sl() instead of str2sl()
10:  b01a0529 = 10:  018358d7 lib/shadow.c: my_sgetspent(): Merge 'else {if}' into 'else if'
11:  0e1edd82 = 11:  e898409a lib/shadow.c: my_sgetspent(): Remove dead code
12:  56f18e94 = 12:  5f5aa6a8 lib/shadow.c: my_sgetspent(): Simplify error handling
13:  9cee75f3 = 13:  4b1a075a src/check_subid_range.c: Call get_uid() instead of str2sl()
14:  413f764a = 14:  2740d61d src/useradd.c: Simplify, by calling a2sl() instead of str2sl()
15:  922ce82f = 15:  a79150cb src/passwd.c: Simplify, by calling a2sl() instead of str2sl()
16:  e324128d = 16:  c7ce1eef src/usermod.c: Simplify, by calling a2sl() instead of str2sl()
17:  7966b682 = 17:  39aa1ee5 src/faillog.c: Simplify, by calling str2sh() instead of str2sl()
18:  fe0cf332 = 18:  0d39c58a src/chage.c: Simplify, by calling a2sl() instead of str2sl()

@alejandro-colomar
Copy link
Collaborator Author

v2c changes:

  • Rebase on master
$ git range-diff gh/strtoll..gh/getuh strtoll..getuh 
 1:  d9ab1ecf =  1:  18952e72 lib/getdef.c: getdef_num(): Simplify, by calling a2si() instead of str2sl()
 2:  367fb843 =  2:  0c33b1f1 lib/getdef.c: getdef_unum(): Fix wrong limit check
 3:  92afbb68 =  3:  4eee2f46 lib/getdef.c: getdef_long(): Simplify, by calling a2sl() instead of str2sl()
 4:  ca682ecc =  4:  2a3e88e5 lib/limits.c: set_prio(): Simplify, by calling str2si() instead of str2sl()
 5:  05221444 =  5:  f33ad154 lib/limits.c: set_umask(): Simplify, by calling str2i(mode_t, ) instead of str2ul()
 6:  2778909f =  6:  f6dfe165 lib/limits.c: setup_limits(): Simplify, by calling a2si() instead of str2sl()
 7:  c7bc89cf =  7:  3050a8e2 lib/limits.c: setup_limits(): Simplify, by calling str2si() instead of str2sl()
 8:  16ee60e8 =  8:  0309a119 lib/limits.c: setup_limits(): Simplify, by calling str2i(mode_t, ) instead of str2ul()
 9:  25dcaab2 =  9:  6817d131 lib/sgetspent.c: sgetspent(): Simplify, by calling a2sl() instead of str2sl()
10:  018358d7 = 10:  98662e5c lib/shadow.c: my_sgetspent(): Merge 'else {if}' into 'else if'
11:  e898409a = 11:  aceb3132 lib/shadow.c: my_sgetspent(): Remove dead code
12:  5f5aa6a8 = 12:  d72aaf42 lib/shadow.c: my_sgetspent(): Simplify error handling
13:  4b1a075a = 13:  eadbbb59 src/check_subid_range.c: Call get_uid() instead of str2sl()
14:  2740d61d = 14:  2b7c4b6d src/useradd.c: Simplify, by calling a2sl() instead of str2sl()
15:  a79150cb = 15:  107ba466 src/passwd.c: Simplify, by calling a2sl() instead of str2sl()
16:  c7ce1eef = 16:  b16dc391 src/usermod.c: Simplify, by calling a2sl() instead of str2sl()
17:  39aa1ee5 = 17:  2a33c67c src/faillog.c: Simplify, by calling str2sh() instead of str2sl()
18:  0d39c58a = 18:  74ccb043 src/chage.c: Simplify, by calling a2sl() instead of str2sl()

@alejandro-colomar
Copy link
Collaborator Author

v2d changes:

  • Rebase on master
$ git range-diff gh/strtoll..gh/getuh strtoll..getuh 
 1:  18952e72 =  1:  b9774fd7 lib/getdef.c: getdef_num(): Simplify, by calling a2si() instead of str2sl()
 2:  0c33b1f1 =  2:  0a1b24ac lib/getdef.c: getdef_unum(): Fix wrong limit check
 3:  4eee2f46 =  3:  97647821 lib/getdef.c: getdef_long(): Simplify, by calling a2sl() instead of str2sl()
 4:  2a3e88e5 =  4:  52a0567b lib/limits.c: set_prio(): Simplify, by calling str2si() instead of str2sl()
 5:  f33ad154 =  5:  5024e5fb lib/limits.c: set_umask(): Simplify, by calling str2i(mode_t, ) instead of str2ul()
 6:  f6dfe165 =  6:  d2717ea3 lib/limits.c: setup_limits(): Simplify, by calling a2si() instead of str2sl()
 7:  3050a8e2 =  7:  e9d5fac7 lib/limits.c: setup_limits(): Simplify, by calling str2si() instead of str2sl()
 8:  0309a119 =  8:  4dbfec39 lib/limits.c: setup_limits(): Simplify, by calling str2i(mode_t, ) instead of str2ul()
 9:  6817d131 =  9:  f6f992bc lib/sgetspent.c: sgetspent(): Simplify, by calling a2sl() instead of str2sl()
10:  98662e5c = 10:  f2e2ce83 lib/shadow.c: my_sgetspent(): Merge 'else {if}' into 'else if'
11:  aceb3132 = 11:  a53d20c9 lib/shadow.c: my_sgetspent(): Remove dead code
12:  d72aaf42 = 12:  08c43628 lib/shadow.c: my_sgetspent(): Simplify error handling
13:  eadbbb59 = 13:  31ef23d7 src/check_subid_range.c: Call get_uid() instead of str2sl()
14:  2b7c4b6d = 14:  ecc58525 src/useradd.c: Simplify, by calling a2sl() instead of str2sl()
15:  107ba466 = 15:  3bace38e src/passwd.c: Simplify, by calling a2sl() instead of str2sl()
16:  b16dc391 = 16:  744e03f6 src/usermod.c: Simplify, by calling a2sl() instead of str2sl()
17:  2a33c67c = 17:  2c54da3f src/faillog.c: Simplify, by calling str2sh() instead of str2sl()
18:  74ccb043 = 18:  1304c7fb src/chage.c: Simplify, by calling a2sl() instead of str2sl()

@alejandro-colomar
Copy link
Collaborator Author

v2e changes:

  • Rebase
$ git range-diff gh/strtoll..gh/getuh strtoll..getuh 
 1:  b9774fd7 =  1:  1b50090c lib/getdef.c: getdef_num(): Simplify, by calling a2si() instead of str2sl()
 2:  0a1b24ac =  2:  2992a9b1 lib/getdef.c: getdef_unum(): Fix wrong limit check
 3:  97647821 =  3:  b7de9cd0 lib/getdef.c: getdef_long(): Simplify, by calling a2sl() instead of str2sl()
 4:  52a0567b =  4:  24f2eb29 lib/limits.c: set_prio(): Simplify, by calling str2si() instead of str2sl()
 5:  5024e5fb =  5:  54c940f8 lib/limits.c: set_umask(): Simplify, by calling str2i(mode_t, ) instead of str2ul()
 6:  d2717ea3 =  6:  24fda133 lib/limits.c: setup_limits(): Simplify, by calling a2si() instead of str2sl()
 7:  e9d5fac7 =  7:  6e53104a lib/limits.c: setup_limits(): Simplify, by calling str2si() instead of str2sl()
 8:  4dbfec39 =  8:  edd8518f lib/limits.c: setup_limits(): Simplify, by calling str2i(mode_t, ) instead of str2ul()
 9:  f6f992bc =  9:  03396c65 lib/sgetspent.c: sgetspent(): Simplify, by calling a2sl() instead of str2sl()
10:  f2e2ce83 = 10:  6c3a9651 lib/shadow.c: my_sgetspent(): Merge 'else {if}' into 'else if'
11:  a53d20c9 = 11:  c3883ff7 lib/shadow.c: my_sgetspent(): Remove dead code
12:  08c43628 = 12:  9cd9ea09 lib/shadow.c: my_sgetspent(): Simplify error handling
13:  31ef23d7 = 13:  21e0afa0 src/check_subid_range.c: Call get_uid() instead of str2sl()
14:  ecc58525 = 14:  17f29a29 src/useradd.c: Simplify, by calling a2sl() instead of str2sl()
15:  3bace38e = 15:  1024afed src/passwd.c: Simplify, by calling a2sl() instead of str2sl()
16:  744e03f6 = 16:  1f67872f src/usermod.c: Simplify, by calling a2sl() instead of str2sl()
17:  2c54da3f = 17:  35c20371 src/faillog.c: Simplify, by calling str2sh() instead of str2sl()
18:  1304c7fb = 18:  d3af3c95 src/chage.c: Simplify, by calling a2sl() instead of str2sl()

@alejandro-colomar
Copy link
Collaborator Author

v2f changes:

  • Rebase
$ git range-diff gh/strtoll..gh/getuh strtoll..getuh 
 1:  1b50090c =  1:  806f0ff5 lib/getdef.c: getdef_num(): Simplify, by calling a2si() instead of str2sl()
 2:  2992a9b1 =  2:  f0181f03 lib/getdef.c: getdef_unum(): Fix wrong limit check
 3:  b7de9cd0 =  3:  6d9d10eb lib/getdef.c: getdef_long(): Simplify, by calling a2sl() instead of str2sl()
 4:  24f2eb29 =  4:  f4692dc4 lib/limits.c: set_prio(): Simplify, by calling str2si() instead of str2sl()
 5:  54c940f8 =  5:  36614d26 lib/limits.c: set_umask(): Simplify, by calling str2i(mode_t, ) instead of str2ul()
 6:  24fda133 =  6:  b9dcbb2b lib/limits.c: setup_limits(): Simplify, by calling a2si() instead of str2sl()
 7:  6e53104a =  7:  9df29b9f lib/limits.c: setup_limits(): Simplify, by calling str2si() instead of str2sl()
 8:  edd8518f =  8:  d0f99086 lib/limits.c: setup_limits(): Simplify, by calling str2i(mode_t, ) instead of str2ul()
 9:  03396c65 =  9:  e143fb48 lib/sgetspent.c: sgetspent(): Simplify, by calling a2sl() instead of str2sl()
10:  6c3a9651 = 10:  402bec05 lib/shadow.c: my_sgetspent(): Merge 'else {if}' into 'else if'
11:  c3883ff7 = 11:  a88d11a7 lib/shadow.c: my_sgetspent(): Remove dead code
12:  9cd9ea09 = 12:  2af1a7bf lib/shadow.c: my_sgetspent(): Simplify error handling
13:  21e0afa0 = 13:  aff746c6 src/check_subid_range.c: Call get_uid() instead of str2sl()
14:  17f29a29 = 14:  dbe51a22 src/useradd.c: Simplify, by calling a2sl() instead of str2sl()
15:  1024afed = 15:  5359d519 src/passwd.c: Simplify, by calling a2sl() instead of str2sl()
16:  1f67872f = 16:  321774db src/usermod.c: Simplify, by calling a2sl() instead of str2sl()
17:  35c20371 = 17:  48461308 src/faillog.c: Simplify, by calling str2sh() instead of str2sl()
18:  d3af3c95 = 18:  38704923 src/chage.c: Simplify, by calling a2sl() instead of str2sl()

…r2sl()

Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
The limit, since it's an unsigned int, should have been UINT_MAX, not
INT_MAX.  By calling a2ui() we can fix that and simplify too.

Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
…tr2sl()

Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
…r2sl()

Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
…ad of str2ul()

Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
…str2sl()

Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
…f str2sl()

Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
…stead of str2ul()

Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
…str2sl()

Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
This reduces indentation.

Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
spwd.sp_flag is an unsigned long, which can never be negative.

Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Handle negative values as errors from a2sl(), and reuse its
error-handling code.

Cc: Iker Pedrosa <ipedrosa@redhat.com>
Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
@alejandro-colomar
Copy link
Collaborator Author

v5c

$ git range-diff master..gh/getuh shadow/master..getuh 
 1:  ffca6d40 !  1:  75ff0ef8 lib/getdef.c: getdef_num(): Simplify, by calling a2si() instead of str2sl()
    @@ Metadata
      ## Commit message ##
         lib/getdef.c: getdef_num(): Simplify, by calling a2si() instead of str2sl()
     
    +    Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
         Signed-off-by: Alejandro Colomar <alx@kernel.org>
     
      ## lib/getdef.c ##
 2:  f568010e !  2:  486f1713 lib/getdef.c: getdef_unum(): Fix wrong limit check
    @@ Commit message
         The limit, since it's an unsigned int, should have been UINT_MAX, not
         INT_MAX.  By calling a2ui() we can fix that and simplify too.
     
    +    Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
         Signed-off-by: Alejandro Colomar <alx@kernel.org>
     
      ## lib/getdef.c ##
 3:  f872fb97 !  3:  8cf383ab lib/getdef.c: getdef_long(): Simplify, by calling a2sl() instead of str2sl()
    @@ Metadata
      ## Commit message ##
         lib/getdef.c: getdef_long(): Simplify, by calling a2sl() instead of str2sl()
     
    +    Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
         Signed-off-by: Alejandro Colomar <alx@kernel.org>
     
      ## lib/getdef.c ##
 4:  6ec310ee !  4:  460281f4 lib/limits.c: set_prio(): Simplify, by calling str2si() instead of str2sl()
    @@ Metadata
      ## Commit message ##
         lib/limits.c: set_prio(): Simplify, by calling str2si() instead of str2sl()
     
    +    Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
         Signed-off-by: Alejandro Colomar <alx@kernel.org>
     
      ## lib/limits.c ##
 5:  1654022c !  5:  af08236d lib/limits.c: set_umask(): Simplify, by calling str2i(mode_t, ) instead of str2ul()
    @@ Metadata
      ## Commit message ##
         lib/limits.c: set_umask(): Simplify, by calling str2i(mode_t, ) instead of str2ul()
     
    +    Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
         Signed-off-by: Alejandro Colomar <alx@kernel.org>
     
      ## lib/limits.c ##
 6:  b5c15c64 !  6:  eda78bbe lib/limits.c: setup_limits(): Simplify, by calling a2si() instead of str2sl()
    @@ Metadata
      ## Commit message ##
         lib/limits.c: setup_limits(): Simplify, by calling a2si() instead of str2sl()
     
    +    Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
         Signed-off-by: Alejandro Colomar <alx@kernel.org>
     
      ## lib/limits.c ##
 7:  2a14ebf4 !  7:  f8978b90 lib/limits.c: setup_limits(): Simplify, by calling str2si() instead of str2sl()
    @@ Metadata
      ## Commit message ##
         lib/limits.c: setup_limits(): Simplify, by calling str2si() instead of str2sl()
     
    +    Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
         Signed-off-by: Alejandro Colomar <alx@kernel.org>
     
      ## lib/limits.c ##
 8:  d2315991 !  8:  aeab8141 lib/limits.c: setup_limits(): Simplify, by calling str2i(mode_t, ) instead of str2ul()
    @@ Metadata
      ## Commit message ##
         lib/limits.c: setup_limits(): Simplify, by calling str2i(mode_t, ) instead of str2ul()
     
    +    Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
         Signed-off-by: Alejandro Colomar <alx@kernel.org>
     
      ## lib/limits.c ##
 9:  0b3e6c8b !  9:  d2c21ccc lib/sgetspent.c: sgetspent(): Simplify, by calling a2sl() instead of str2sl()
    @@ Metadata
      ## Commit message ##
         lib/sgetspent.c: sgetspent(): Simplify, by calling a2sl() instead of str2sl()
     
    +    Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
         Signed-off-by: Alejandro Colomar <alx@kernel.org>
     
      ## lib/sgetspent.c ##
10:  c29af369 ! 10:  5fc42d87 lib/shadow.c: my_sgetspent(): Merge 'else {if}' into 'else if'
    @@ Commit message
     
         This reduces indentation.
     
    +    Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
         Signed-off-by: Alejandro Colomar <alx@kernel.org>
     
      ## lib/shadow.c ##
11:  5f497e9e ! 11:  4532f48b lib/shadow.c: my_sgetspent(): Remove dead code
    @@ Commit message
     
         spwd.sp_flag is an unsigned long, which can never be negative.
     
    +    Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
         Signed-off-by: Alejandro Colomar <alx@kernel.org>
     
      ## lib/shadow.c ##
12:  e7dcdb4c ! 12:  3d4d2268 lib/shadow.c: my_sgetspent(): Simplify error handling
    @@ Commit message
         error-handling code.
     
         Cc: Iker Pedrosa <ipedrosa@redhat.com>
    -    Cc: "Serge E. Hallyn" <serge@hallyn.com>
    +    Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
         Signed-off-by: Alejandro Colomar <alx@kernel.org>
     
      ## lib/shadow.c ##
13:  aea35eb6 ! 13:  52780d19 src/: Use get_[ug]id() where appropriate
    @@ Metadata
      ## Commit message ##
         src/: Use get_[ug]id() where appropriate
     
    +    Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
         Signed-off-by: Alejandro Colomar <alx@kernel.org>
     
      ## src/check_subid_range.c ##
14:  1be8cd81 ! 14:  caee6dd3 src/useradd.c: Simplify, by calling a2sl() instead of str2sl()
    @@ Metadata
      ## Commit message ##
         src/useradd.c: Simplify, by calling a2sl() instead of str2sl()
     
    +    Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
         Signed-off-by: Alejandro Colomar <alx@kernel.org>
     
      ## src/useradd.c ##
15:  6a61fefd ! 15:  6ce8defe src/passwd.c: Simplify, by calling a2sl() instead of str2sl()
    @@ Metadata
      ## Commit message ##
         src/passwd.c: Simplify, by calling a2sl() instead of str2sl()
     
    +    Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
         Signed-off-by: Alejandro Colomar <alx@kernel.org>
     
      ## src/passwd.c ##
16:  bca3a624 ! 16:  94a66789 src/usermod.c: Simplify, by calling a2sl() instead of str2sl()
    @@ Metadata
      ## Commit message ##
         src/usermod.c: Simplify, by calling a2sl() instead of str2sl()
     
    +    Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
         Signed-off-by: Alejandro Colomar <alx@kernel.org>
     
      ## src/usermod.c ##
17:  def0a300 ! 17:  9c9ddbcd src/faillog.c: Simplify, by calling str2sh() instead of str2sl()
    @@ Metadata
      ## Commit message ##
         src/faillog.c: Simplify, by calling str2sh() instead of str2sl()
     
    +    Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
         Signed-off-by: Alejandro Colomar <alx@kernel.org>
     
      ## src/faillog.c ##
18:  6b176d86 ! 18:  8cfe6e1c src/chage.c: Simplify, by calling a2sl() instead of str2sl()
    @@ Metadata
      ## Commit message ##
         src/chage.c: Simplify, by calling a2sl() instead of str2sl()
     
    +    Reviewed-by: "Serge E. Hallyn" <serge@hallyn.com>
         Signed-off-by: Alejandro Colomar <alx@kernel.org>
     
      ## src/chage.c ##

@alejandro-colomar alejandro-colomar merged commit b38ee0c into shadow-maint:master Jul 2, 2024
8 checks passed
@alejandro-colomar alejandro-colomar deleted the getuh branch July 2, 2024 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants