From: Karel Zak Date: Wed, 12 Feb 2025 09:33:58 +0000 (+0100) Subject: ipc: coding style cosmetic changes X-Git-Tag: v2.42-start~53 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6a2b05d8ac3c2f1546fc5977ecfa7da2709b114a;p=thirdparty%2Futil-linux.git ipc: coding style cosmetic changes * Removed trailing white space * Added comments to long #endif statements * Improved indentation in some places * Reduced size of lsipc --help lines Signed-off-by: Karel Zak --- diff --git a/configure.ac b/configure.ac index c42591bd5..ca7607373 100644 --- a/configure.ac +++ b/configure.ac @@ -356,7 +356,7 @@ AC_CHECK_HEADERS([ \ linux/if_alg.h \ locale.h \ mntent.h \ - mqueue.h \ + mqueue.h \ net/if_dl.h \ net/if.h \ netinet/in.h \ @@ -364,7 +364,7 @@ AC_CHECK_HEADERS([ \ pty.h \ security/pam_appl.h \ security/pam_modules.h \ - semaphore.h \ + semaphore.h \ shadow.h \ stdint.h \ stdio_ext.h \ @@ -377,7 +377,7 @@ AC_CHECK_HEADERS([ \ sys/ioctl.h \ sys/io.h \ sys/mkdev.h \ - sys/mman.h \ + sys/mman.h \ sys/mount.h \ sys/param.h \ sys/pidfd.h \ diff --git a/sys-utils/ipcmk.c b/sys-utils/ipcmk.c index 32c23f79f..5fa5869c6 100644 --- a/sys-utils/ipcmk.c +++ b/sys-utils/ipcmk.c @@ -34,16 +34,16 @@ #include #ifdef HAVE_MQUEUE_H -#include +# include #endif #ifdef HAVE_SEMAPHORE_H -#include +# include #endif #ifdef HAVE_SYS_MMAN_H -#include -#include +# include +# include #endif #include "c.h" @@ -62,8 +62,8 @@ static int create_shm(size_t size, int permission) #ifndef HAVE_SYS_MMAN_H static int create_posix_shm(const char *name __attribute__((__unused__)), - size_t size __attribute__((__unused__)), - int permission __attribute__((__unused__))) + size_t size __attribute__((__unused__)), + int permission __attribute__((__unused__))) { warnx(_("POSIX shared memory is not supported")); return -1; @@ -75,7 +75,7 @@ static int create_posix_shm(const char *name, size_t size, int permission) if (-1 == (shmfd = shm_open(name, O_RDWR | O_CREAT, permission))) return -1; - + if (-1 == ftruncate(shmfd, size)) { close(shmfd); return -1; @@ -97,7 +97,7 @@ static int create_msg(int permission) #ifndef HAVE_MQUEUE_H static int create_posix_msg(const char *name __attribute__((__unused__)), - int permission __attribute__((__unused__))) + int permission __attribute__((__unused__))) { warnx(_("POSIX message queue is not supported")); return -1; @@ -126,7 +126,7 @@ static int create_sem(int nsems, int permission) #ifndef HAVE_SEMAPHORE_H static int create_posix_sem(const char *name __attribute__((__unused__)), - int permission __attribute__((__unused__))) + int permission __attribute__((__unused__))) { warnx(_("POSIX semaphore is not supported")); return -1; diff --git a/sys-utils/ipcutils.c b/sys-utils/ipcutils.c index df6d15dd6..a755849fb 100644 --- a/sys-utils/ipcutils.c +++ b/sys-utils/ipcutils.c @@ -52,7 +52,7 @@ int ipc_msg_get_limits(struct ipc_limits *lim) } /* POSIX IPC */ - #ifdef HAVE_MQUEUE_H +#ifdef HAVE_MQUEUE_H FILE *f; f = fopen(_PATH_PROC_POSIX_IPC_MSGMNI, "r"); @@ -75,8 +75,7 @@ int ipc_msg_get_limits(struct ipc_limits *lim) lim->msgmax_posix = 0; fclose(f); } - #endif - +#endif return 0; } @@ -255,7 +254,7 @@ void ipc_shm_free_info(struct shm_data *shmds) #ifndef HAVE_SYS_MMAN_H int posix_ipc_shm_get_info(const char *name __attribute__((unused)), - struct posix_shm_data **shmds __attribute__((unused))) + struct posix_shm_data **shmds __attribute__((unused))) { warnx(_("POSIX shared memory is not supported")); return -1; @@ -316,7 +315,7 @@ int posix_ipc_shm_get_info(const char *name, struct posix_shm_data **shmds) closedir(d); return i; } -#endif +#endif /* HAVE_SYS_MMAN_H */ void posix_ipc_shm_free_info(struct posix_shm_data *shmds) { @@ -468,7 +467,7 @@ void ipc_sem_free_info(struct sem_data *semds) #ifndef HAVE_SEMAPHORE_H int posix_ipc_sem_get_info(const char *name __attribute__((__unused__)), - struct posix_sem_data **semds __attribute__((__unused__))) + struct posix_sem_data **semds __attribute__((__unused__))) { warnx(_("POSIX semaphore is not supported")); return -1; @@ -534,7 +533,7 @@ int posix_ipc_sem_get_info(const char *name, struct posix_sem_data **semds) closedir(d); return i; } -#endif +#endif /* HAVE_SEMAPHORE_H */ void posix_ipc_sem_free_info(struct posix_sem_data *semds) { @@ -658,7 +657,7 @@ void ipc_msg_free_info(struct msg_data *msgds) #ifndef HAVE_MQUEUE_H int posix_ipc_msg_get_info(const char *name __attribute__((unused)), - struct posix_msg_data **msgds __attribute__((unused))) + struct posix_msg_data **msgds __attribute__((unused))) { warnx(_("POSIX message queues are not supported")); return -1; @@ -749,7 +748,7 @@ int posix_ipc_msg_get_info(const char *name, struct posix_msg_data **msgds) return i; } -#endif +#endif /* HAVE_MQUEUE_H */ void posix_ipc_msg_free_info(struct posix_msg_data *msgds) { diff --git a/sys-utils/lsipc.c b/sys-utils/lsipc.c index c3cc63f51..58cf515de 100644 --- a/sys-utils/lsipc.c +++ b/sys-utils/lsipc.c @@ -181,7 +181,7 @@ static const struct lsipc_coldesc coldescs[] = [COL_CTIME] = { "CTIME", N_("Time of the last change"), N_("Last change"), 1, SCOLS_FL_RIGHT}, /* posix-common */ - [COL_NAME] = { "NAME", N_("POSIX resource name"), N_("Name"), 1 }, + [COL_NAME] = { "NAME", N_("POSIX resource name"), N_("Name"), 1 }, [COL_MTIME] = { "MTIME", N_("Time of last action"), N_("Last action"), 1, SCOLS_FL_RIGHT}, /* msgq-specific */ @@ -322,21 +322,22 @@ static void __attribute__((__noreturn__)) usage(void) fputs(USAGE_SEPARATOR, out); fputs(_("Resource options:\n"), out); - fputs(_(" -m, --shmems shared memory segments\n"), out); - fputs(_(" -M, --posix-shmems POSIX shared memory segments\n"), out); - fputs(_(" -q, --queues message queues\n"), out); - fputs(_(" -Q, --posix-mqueues POSIX message queues\n"), out); - fputs(_(" -s, --semaphores semaphores\n"), out); - fputs(_(" -S, --posix-semaphores POSIX semaphores\n"), out); - fputs(_(" -g, --global info about system-wide usage (may be used with -m, -q and -s)\n"), out); - fputs(_(" -i, --id print details on resource identified by \n"), out); - fputs(_(" -N, --name print details on posix resource identified by \n"), out); + fputs(_(" -m, --shmems shared memory segments\n"), out); + fputs(_(" -M, --posix-shmems POSIX shared memory segments\n"), out); + fputs(_(" -q, --queues message queues\n"), out); + fputs(_(" -Q, --posix-mqueues POSIX message queues\n"), out); + fputs(_(" -s, --semaphores semaphores\n"), out); + fputs(_(" -S, --posix-semaphores POSIX semaphores\n"), out); + fputs(_(" -g, --global info about system-wide usage\n" + " (may be used with -m, -q and -s)\n"), out); + fputs(_(" -i, --id System V resource identified by \n"), out); + fputs(_(" -N, --name POSIX resource identified by \n"), out); fputs(USAGE_OPTIONS, out); fputs(_(" --noheadings don't print headings\n"), out); fputs(_(" --notruncate don't truncate output\n"), out); fputs(_(" --time-format= display dates in short, full or iso format\n"), out); - fputs(_(" -b, --bytes print SIZE in bytes rather than in human readable format\n"), out); + fputs(_(" -b, --bytes print SIZE in bytes rather\n"), out); fputs(_(" -c, --creator show creator and owner\n"), out); fputs(_(" -e, --export display in an export-able output format\n"), out); fputs(_(" -J, --json use the JSON output format\n"), out); @@ -346,7 +347,7 @@ static void __attribute__((__noreturn__)) usage(void) fputs(_(" -P, --numeric-perms print numeric permissions (PERMS column)\n"), out); fputs(_(" -r, --raw display in raw mode\n"), out); fputs(_(" -t, --time show attach, detach and change times\n"), out); - fputs(_(" -y, --shell use column names to be usable as shell variable identifiers\n"), out); + fputs(_(" -y, --shell use column names to be usable as shell variables\n"), out); fputs(USAGE_SEPARATOR, out); @@ -355,7 +356,7 @@ static void __attribute__((__noreturn__)) usage(void) fprintf(out, _("\nGeneric System V columns:\n")); for (i = COLDESC_IDX_GEN_FIRST; i <= COLDESC_IDX_GEN_LAST; i++) fprintf(out, " %14s %s\n", coldescs[i].name, _(coldescs[i].help)); - + fprintf(out, _("\nGeneric POSIX columns:\n")); fprintf(out, " %14s %s\n", coldescs[COL_NAME].name, _(coldescs[COL_NAME].help)); for (i = COLDESC_IDX_GEN_POSIX_FIRST; i <= COLDSEC_IDX_GEN_POSIX_LAST; i++) @@ -768,7 +769,8 @@ static void do_sem_global(struct lsipc_control *ctl, struct libscols_table *tb) global_set_data(ctl, tb, "SEMVMX", _("Semaphore max value"), 0, lim.semvmx, 0, 0); } -static void do_posix_sem(const char *name, struct lsipc_control *ctl, struct libscols_table *tb) +static void do_posix_sem(const char *name, struct lsipc_control *ctl, + struct libscols_table *tb) { struct libscols_line *ln; struct passwd *pw = NULL; @@ -855,7 +857,7 @@ static void do_posix_sem(const char *name, struct lsipc_control *ctl, struct lib arg = NULL; } if (name != NULL) - break; + break; } posix_ipc_sem_free_info(semds); } @@ -993,9 +995,10 @@ static void do_msg(int id, struct lsipc_control *ctl, struct libscols_table *tb) ipc_msg_free_info(msgds); } -static void do_posix_msg(const char *name, struct lsipc_control *ctl, struct libscols_table *tb) +static void do_posix_msg(const char *name, struct lsipc_control *ctl, + struct libscols_table *tb) { - struct libscols_line *ln; + struct libscols_line *ln; struct passwd *pw = NULL; struct group *gr = NULL; struct posix_msg_data *msgds, *p; @@ -1092,7 +1095,7 @@ static void do_posix_msg(const char *name, struct lsipc_control *ctl, struct lib break; } posix_ipc_msg_free_info(msgds); -} +} static void do_msg_global(struct lsipc_control *ctl, struct libscols_table *tb) { @@ -1482,7 +1485,7 @@ int main(int argc, char *argv[]) { 'J', 'e', 'l', 'n', 'r' }, { 'N', 'g', 'i' }, { 'c', 'o', 't' }, - { 'M', 'Q', 'S', 'm', 'q', 's' }, + { 'M', 'Q', 'S', 'm', 'q', 's' }, { 0 } }; int excl_st[ARRAY_SIZE(excl)] = UL_EXCL_STATUS_INIT;