summaryrefslogtreecommitdiff
path: root/libgcompat/pwd.c
diff options
context:
space:
mode:
Diffstat (limited to 'libgcompat/pwd.c')
-rw-r--r--libgcompat/pwd.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/libgcompat/pwd.c b/libgcompat/pwd.c
index 2e09aea..50d8da0 100644
--- a/libgcompat/pwd.c
+++ b/libgcompat/pwd.c
@@ -1,23 +1,27 @@
/* some musl versions incorrectly mark fgetpwent() as a GNU extension */
#define _GNU_SOURCE
-#include <stdio.h>
#include <errno.h>
#include <pwd.h>
+#include <stdio.h>
#include <string.h>
-
-int getpwent_r(struct passwd *pwbuf, char *buf, size_t buflen, struct passwd **pwbufp) {
+int getpwent_r(struct passwd *pwbuf, char *buf, size_t buflen,
+ struct passwd **pwbufp)
+{
struct passwd *pwd;
- if (pwbufp == NULL || pwbuf == NULL)
+ if (pwbufp == NULL || pwbuf == NULL) {
return ERANGE;
+ }
- if (buflen < 1)
+ if (buflen < 1) {
return ERANGE;
+ }
- if (buf != NULL)
+ if (buf != NULL) {
*buf = '\0';
+ }
if ((pwd = getpwent()) == NULL) {
*pwbufp = NULL;
@@ -30,18 +34,22 @@ int getpwent_r(struct passwd *pwbuf, char *buf, size_t buflen, struct passwd **p
return 0;
}
-
-int fgetpwent_r(FILE *filp, struct passwd *pwbuf, char *buf, size_t buflen, struct passwd **pwbufp) {
+int fgetpwent_r(FILE *filp, struct passwd *pwbuf, char *buf, size_t buflen,
+ struct passwd **pwbufp)
+{
struct passwd *pwd;
- if (pwbufp == NULL || pwbuf == NULL)
+ if (pwbufp == NULL || pwbuf == NULL) {
return ERANGE;
+ }
- if (buflen < 1)
+ if (buflen < 1) {
return ERANGE;
+ }
- if (buf != NULL)
+ if (buf != NULL) {
*buf = '\0';
+ }
if ((pwd = fgetpwent(filp)) == NULL) {
*pwbufp = NULL;