From: Collin Funk Date: Sun, 21 Dec 2025 01:24:17 +0000 (-0800) Subject: maint: prefer enums over macros for sources used for multiple programs X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1313c240569db9dbf5814332a05020c196334418;p=thirdparty%2Fcoreutils.git maint: prefer enums over macros for sources used for multiple programs * src/chown.h (enum chown_modes): New type. (CHOWN_CHOWN, CHOWN_CHGRP): Define as an enum instead of a macro. * src/chown-chgrp.c (chown_mode): Use "enum chown_modes" instead of "int". * src/chown-chown.c (chown_mode): Likewise. * src/ls.h (enum ls_modes): New type. (LS_LS, LS_MULTI_COL, LS_LONG_FORMAT): Define as an enum instead of a macro. * src/ls-dir.c (ls_mode): Use "enum ls_modes" instead of "int". * src/ls-ls.c (ls_mode): Likewise. * src/ls-vdir.c (ls_mode): Likewise. * src/uname.h (enum uname_modes): New type. (UNAME_UNAME, UNAME_ARCH): Define as an enum instead of a macro. * src/uname-arch.c (uname_mode): Use "enum uname_modes" instead of "int". * src/uname-uname.c (uname_mode): Likewise. --- diff --git a/src/chown-chgrp.c b/src/chown-chgrp.c index aa0b180074..fb076d136f 100644 --- a/src/chown-chgrp.c +++ b/src/chown-chgrp.c @@ -1,2 +1,2 @@ #include "chown.h" -int chown_mode = CHOWN_CHGRP; +enum chown_modes chown_mode = CHOWN_CHGRP; diff --git a/src/chown-chown.c b/src/chown-chown.c index 9531fa2603..b11873a4b7 100644 --- a/src/chown-chown.c +++ b/src/chown-chown.c @@ -1,2 +1,2 @@ #include "chown.h" -int chown_mode = CHOWN_CHOWN; +enum chown_modes chown_mode = CHOWN_CHOWN; diff --git a/src/chown.h b/src/chown.h index 21f01c4054..0f87a8832f 100644 --- a/src/chown.h +++ b/src/chown.h @@ -1,7 +1,10 @@ -/* This is for the 'chown' program. */ -#define CHOWN_CHOWN 1 +enum chown_modes +{ + /* This is for the 'chown' program. */ + CHOWN_CHOWN, -/* This is for the 'chgrp' program. */ -#define CHOWN_CHGRP 2 + /* This is for the 'chgrp' program. */ + CHOWN_CHGRP, +}; -extern int chown_mode; +extern enum chown_modes chown_mode; diff --git a/src/ls-dir.c b/src/ls-dir.c index 85fe242ebf..18420d23a9 100644 --- a/src/ls-dir.c +++ b/src/ls-dir.c @@ -1,2 +1,2 @@ #include "ls.h" -int ls_mode = LS_MULTI_COL; +enum ls_modes ls_mode = LS_MULTI_COL; diff --git a/src/ls-ls.c b/src/ls-ls.c index f33fbbc061..00e5f7ee5f 100644 --- a/src/ls-ls.c +++ b/src/ls-ls.c @@ -1,2 +1,2 @@ #include "ls.h" -int ls_mode = LS_LS; +enum ls_modes ls_mode = LS_LS; diff --git a/src/ls-vdir.c b/src/ls-vdir.c index 36ebf913bc..24c890fbb3 100644 --- a/src/ls-vdir.c +++ b/src/ls-vdir.c @@ -1,2 +1,2 @@ #include "ls.h" -int ls_mode = LS_LONG_FORMAT; +enum ls_modes ls_mode = LS_LONG_FORMAT; diff --git a/src/ls.h b/src/ls.h index b358211973..23ddb9f5e9 100644 --- a/src/ls.h +++ b/src/ls.h @@ -1,10 +1,13 @@ -/* This is for the 'ls' program. */ -#define LS_LS 1 +enum ls_modes +{ + /* This is for the 'ls' program. */ + LS_LS, -/* This is for the 'dir' program. */ -#define LS_MULTI_COL 2 + /* This is for the 'dir' program. */ + LS_MULTI_COL, -/* This is for the 'vdir' program. */ -#define LS_LONG_FORMAT 3 + /* This is for the 'vdir' program. */ + LS_LONG_FORMAT +}; -extern int ls_mode; +extern enum ls_modes ls_mode; diff --git a/src/uname-arch.c b/src/uname-arch.c index eb429424e7..c93a0e65e6 100644 --- a/src/uname-arch.c +++ b/src/uname-arch.c @@ -1,2 +1,2 @@ #include "uname.h" -int uname_mode = UNAME_ARCH; +enum uname_modes uname_mode = UNAME_ARCH; diff --git a/src/uname-uname.c b/src/uname-uname.c index 450245dcc2..f4e0d39ff0 100644 --- a/src/uname-uname.c +++ b/src/uname-uname.c @@ -1,2 +1,2 @@ #include "uname.h" -int uname_mode = UNAME_UNAME; +enum uname_modes uname_mode = UNAME_UNAME; diff --git a/src/uname.h b/src/uname.h index f4da9b0c31..428d8f510e 100644 --- a/src/uname.h +++ b/src/uname.h @@ -1,7 +1,10 @@ -/* This is for the 'uname' program. */ -#define UNAME_UNAME 1 +enum uname_modes +{ + /* This is for the 'uname' program. */ + UNAME_UNAME, -/* This is for the 'arch' program. */ -#define UNAME_ARCH 2 + /* This is for the 'arch' program. */ + UNAME_ARCH +}; -extern int uname_mode; +extern enum uname_modes uname_mode;