Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG. It also introduces reverse xmas tree local
variable declarations and header file reordering.
In summary, this patch fixes the following checkpatch.pl
recommendations:
0 errors, 1 warnings, 82 lines checked
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
* Author: Steve Olivieri <sjo@redhat.com>
*/
-#include <stdio.h>
#include <stdlib.h>
-#include <sys/types.h>
#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <stdio.h>
#include <pwd.h>
#include <grp.h>
-#include <errno.h>
-#include <string.h>
+
+#include <sys/types.h>
/*
* This is just a simple program for changing a UID or a GID. Comment out
int ret = 0;
if (argc < 2) {
- printf("Usage: %s <uid_value> \n", argv[0]);
+ printf("Usage: %s <uid_value>\n", argv[0]);
goto finished;
}
pwd = getpwnam(argv[1]);
if (!pwd) {
fprintf(stderr, "getpwnam() failed: %s\n",
- strerror(errno));
+ strerror(errno));
ret = -errno;
goto finished;
}
+
uid = pwd->pw_uid;
fprintf(stdout, "Setting UID to %s (%d).\n", pwd->pw_name, uid);
- if ((ret = setuid(uid))) {
+ ret = setuid(uid);
+ if (ret != 0) {
fprintf(stderr, "Call to setuid() failed with error: %s\n",
- strerror(errno));
+ strerror(errno));
ret = -errno;
goto finished;
}
// }
// }
- while (1) {
+ while (1)
usleep(3000000);
- }
finished:
return ret;