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

Expunge strtoll(3) and strtol(3) #896

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Commits on May 27, 2024

  1. lib/typetraits.h: Add macros that give information about a type

    In the case of is_unsigned() and is_signed(), the natural thing would be
    to compare to 0:
    
    	#define is_unsigned(x)  (((typeof(x)) -1) > 0)
    	#define is_signed(x)    (((typeof(x)) -1) < 0)
    
    However, that would trigger -Wtype-limits, so we compare against 1,
    which silences that, and does the same job.
    
    Signed-off-by: Alejandro Colomar <alx@kernel.org>
    alejandro-colomar committed May 27, 2024
    Configuration menu
    Copy the full SHA
    d06c81f View commit details
    Browse the repository at this point in the history
  2. src/: Use str2[u]l() instead of atoi(3)

    atoi(3) easily triggers Undefined Behavior.  Replace it by str2[u]l(),
    which are safe from that, and add type safety too.
    
    Signed-off-by: Alejandro Colomar <alx@kernel.org>
    alejandro-colomar committed May 27, 2024
    Configuration menu
    Copy the full SHA
    b8e914f View commit details
    Browse the repository at this point in the history
  3. lib/get_gid.c: get_gid(): Reimplement in terms of a2i()

    Signed-off-by: Alejandro Colomar <alx@kernel.org>
    alejandro-colomar committed May 27, 2024
    Configuration menu
    Copy the full SHA
    105697f View commit details
    Browse the repository at this point in the history
  4. lib/, libsubid/, po/, src/: get_gid(): Move function to "atoi/getnum.h"

    Implement it as an inline function, and add restrict and ATTR_STRING()
    and ATTR_ACCESS() as appropriate.
    
    Signed-off-by: Alejandro Colomar <alx@kernel.org>
    alejandro-colomar committed May 27, 2024
    Configuration menu
    Copy the full SHA
    36db6c5 View commit details
    Browse the repository at this point in the history
  5. lib/: Don't open-code get_gid()

    These functions were open-coding get_gid().  Use the actual function.
    
    Signed-off-by: Alejandro Colomar <alx@kernel.org>
    alejandro-colomar committed May 27, 2024
    Configuration menu
    Copy the full SHA
    310b3d8 View commit details
    Browse the repository at this point in the history
  6. lib/get_pid.c: get_pid(): Reimplement in terms of a2i()

    Signed-off-by: Alejandro Colomar <alx@kernel.org>
    alejandro-colomar committed May 27, 2024
    Configuration menu
    Copy the full SHA
    7b9fe7a View commit details
    Browse the repository at this point in the history
  7. lib/: get_pid(): Move function to "atoi/getnum.h"

    Implement it as an inline function, and add restrict and ATTR_STRING()
    and ATTR_ACCESS() as appropriate.
    
    Signed-off-by: Alejandro Colomar <alx@kernel.org>
    alejandro-colomar committed May 27, 2024
    Configuration menu
    Copy the full SHA
    7914f14 View commit details
    Browse the repository at this point in the history
  8. lib/atoi/getnum.[ch]: get_fd(): Add function for parsing a file descr…

    …iptor from a string
    
    Signed-off-by: Alejandro Colomar <alx@kernel.org>
    alejandro-colomar committed May 27, 2024
    Configuration menu
    Copy the full SHA
    7d00e66 View commit details
    Browse the repository at this point in the history
  9. lib/get_pid.c: get_pidfd_from_fd(): Don't open-code get_fd()

    Signed-off-by: Alejandro Colomar <alx@kernel.org>
    alejandro-colomar committed May 27, 2024
    Configuration menu
    Copy the full SHA
    044396c View commit details
    Browse the repository at this point in the history
  10. src/usermod.c: getulong_range(): Reimplement in terms of a2ul()

    Signed-off-by: Alejandro Colomar <alx@kernel.org>
    alejandro-colomar committed May 27, 2024
    Configuration menu
    Copy the full SHA
    0a81ae8 View commit details
    Browse the repository at this point in the history
  11. lib/get_uid.c: get_uid(): Reimplement in terms of a2i()

    Signed-off-by: Alejandro Colomar <alx@kernel.org>
    alejandro-colomar committed May 27, 2024
    Configuration menu
    Copy the full SHA
    d9e31c7 View commit details
    Browse the repository at this point in the history
  12. lib/, po/, src/: get_uid(): Move function to "atoi/getnum.h"

    Implement it as an inline function, and add restrict and ATTR_STRING()
    and ATTR_ACCESS() as appropriate.
    
    Signed-off-by: Alejandro Colomar <alx@kernel.org>
    alejandro-colomar committed May 27, 2024
    Configuration menu
    Copy the full SHA
    5332860 View commit details
    Browse the repository at this point in the history
  13. lib/limits.c: setrlimit_value(): Reimplement in terms of a2i()

    Signed-off-by: Alejandro Colomar <alx@kernel.org>
    alejandro-colomar committed May 27, 2024
    Configuration menu
    Copy the full SHA
    4d4b471 View commit details
    Browse the repository at this point in the history
  14. src/usermod.c: Fix const correctness

    Now that we use liba2i's const-generic macros, we can (and must) use a
    'const char **' endp where the input string is 'const char *'.
    
    Signed-off-by: Alejandro Colomar <alx@kernel.org>
    alejandro-colomar committed May 27, 2024
    Configuration menu
    Copy the full SHA
    b85ad7a View commit details
    Browse the repository at this point in the history