Skip to content

Commit

Permalink
pwd.h: add __nonnull markings [BZ #18641]
Browse files Browse the repository at this point in the history
Mark all the functions that don't handle NULL pointers as __nonnull.
POSIX does not require either behavior, so the prototypes should match
the reality of the codebase.
  • Loading branch information
Mike Frysinger committed Jul 8, 2015
1 parent 8b59c73 commit 61d9539
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
11 changes: 11 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
2015-07-08 Mike Frysinger <vapier@gentoo.org>

[BZ #18641]
* pwd/pwd.h (fgetpwent): Add __nonnull markings.
(putpwent): Likewise.
(getpwnam): Likewise.
(getpwent_r): Likewise.
(getpwuid_r): Likewise.
(getpwnam_r): Likewise.
(fgetpwent_r): Likewise.

2015-06-18 Carlos O'Donell <carlos@redhat.com>

[BZ #18557]
Expand Down
2 changes: 1 addition & 1 deletion NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Version 2.22
18519, 18520, 18522, 18527, 18528, 18529, 18530, 18532, 18533, 18534,
18536, 18539, 18540, 18542, 18544, 18545, 18546, 18547, 18549, 18553,
18557, 18558, 18569, 18583, 18585, 18586, 18592, 18593, 18594, 18602,
18612, 18613, 18619, 18633.
18612, 18613, 18619, 18633, 18641.

* Cache information can be queried via sysconf() function on s390 e.g. with
_SC_LEVEL1_ICACHE_SIZE as argument.
Expand Down
18 changes: 11 additions & 7 deletions pwd/pwd.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ extern struct passwd *getpwent (void);
cancellation point. But due to similarity with an POSIX interface
or due to the implementation it is a cancellation point and
therefore not marked with __THROW. */
extern struct passwd *fgetpwent (FILE *__stream);
extern struct passwd *fgetpwent (FILE *__stream) __nonnull ((1));

/* Write the given entry onto the given stream.
Expand All @@ -100,7 +100,7 @@ extern struct passwd *fgetpwent (FILE *__stream);
or due to the implementation it is a cancellation point and
therefore not marked with __THROW. */
extern int putpwent (const struct passwd *__restrict __p,
FILE *__restrict __f);
FILE *__restrict __f) __nonnull ((1, 2));
#endif

/* Search for an entry with a matching user ID.
Expand All @@ -113,7 +113,7 @@ extern struct passwd *getpwuid (__uid_t __uid);
This function is a possible cancellation point and therefore not
marked with __THROW. */
extern struct passwd *getpwnam (const char *__name);
extern struct passwd *getpwnam (const char *__name) __nonnull ((1));

#ifdef __USE_POSIX

Expand All @@ -138,18 +138,21 @@ extern struct passwd *getpwnam (const char *__name);
therefore not marked with __THROW. */
extern int getpwent_r (struct passwd *__restrict __resultbuf,
char *__restrict __buffer, size_t __buflen,
struct passwd **__restrict __result);
struct passwd **__restrict __result)
__nonnull ((1, 2, 4));
# endif

extern int getpwuid_r (__uid_t __uid,
struct passwd *__restrict __resultbuf,
char *__restrict __buffer, size_t __buflen,
struct passwd **__restrict __result);
struct passwd **__restrict __result)
__nonnull ((2, 3, 5));

extern int getpwnam_r (const char *__restrict __name,
struct passwd *__restrict __resultbuf,
char *__restrict __buffer, size_t __buflen,
struct passwd **__restrict __result);
struct passwd **__restrict __result)
__nonnull ((1, 2, 3, 5));


# ifdef __USE_MISC
Expand All @@ -163,7 +166,8 @@ extern int getpwnam_r (const char *__restrict __name,
extern int fgetpwent_r (FILE *__restrict __stream,
struct passwd *__restrict __resultbuf,
char *__restrict __buffer, size_t __buflen,
struct passwd **__restrict __result);
struct passwd **__restrict __result)
__nonnull ((1, 2, 3, 5));
# endif

#endif /* POSIX or reentrant */
Expand Down

0 comments on commit 61d9539

Please sign in to comment.