commit: 3beee05fd4a4a48755e919b0090e1c733635b787
parent 080be8f4c0184f2f98599bb9ba0ae5f8612ee835
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Sun, 28 Jul 2024 00:32:06 +0200
cmd/{df,id,nproc}: Match getopt against -1 rather than EOF
Diffstat:
3 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/cmd/df.c b/cmd/df.c
@@ -50,8 +50,8 @@ main(int argc, char *argv[])
size_t only_count = 0;
char *only[4096];
- int c = EOF;
- while((c = getopt(argc, argv, ":ahlPkTt:x:")) != EOF)
+ int c = -1;
+ while((c = getopt(argc, argv, ":ahlPkTt:x:")) != -1)
{
switch(c)
{
diff --git a/cmd/id.c b/cmd/id.c
@@ -160,7 +160,7 @@ usage()
int
main(int argc, char *argv[])
{
- int ret = 0, c = 0;
+ int ret = 0;
enum id_modes mode = ID_NORMAL;
bool real_flag = false;
@@ -182,7 +182,8 @@ main(int argc, char *argv[])
struct passwd pw = {.pw_uid = uid, .pw_gid = gid};
struct passwd epw = {.pw_uid = euid, .pw_gid = egid};
- while((c = getopt(argc, argv, ":Ggunr")) != EOF)
+ int c = -1;
+ while((c = getopt(argc, argv, ":Ggunr")) != -1)
{
switch(c)
{
diff --git a/cmd/nproc.c b/cmd/nproc.c
@@ -20,8 +20,8 @@ main(int argc, char *argv[])
// currently available
int target = _SC_NPROCESSORS_ONLN;
- int c;
- while((c = getopt(argc, argv, ":a")) != EOF)
+ int c = -1;
+ while((c = getopt(argc, argv, ":a")) != -1)
{
switch(c)
{