]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
ipc: coding style cosmetic changes
authorKarel Zak <kzak@redhat.com>
Wed, 12 Feb 2025 09:33:58 +0000 (10:33 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 12 Feb 2025 09:33:58 +0000 (10:33 +0100)
* 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 <kzak@redhat.com>
configure.ac
sys-utils/ipcmk.c
sys-utils/ipcutils.c
sys-utils/lsipc.c

index c42591bd50fe46121032a74dbba8bde7854ab369..ca76073736c656f8f6e277b66775bfb70935bbb3 100644 (file)
@@ -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 \
index 32c23f79fcca5038a5dac9f7eaa828dc301b6728..5fa5869c6ba64cf8a274ce8ce902ee24519fad6a 100644 (file)
 #include <sys/time.h>
 
 #ifdef HAVE_MQUEUE_H
-#include <mqueue.h>
+# include <mqueue.h>
 #endif
 
 #ifdef HAVE_SEMAPHORE_H
-#include <semaphore.h>
+# include <semaphore.h>
 #endif
 
 #ifdef HAVE_SYS_MMAN_H
-#include <sys/stat.h>
-#include <sys/mman.h>
+# include <sys/stat.h>
+# include <sys/mman.h>
 #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;
index df6d15dd6b8fe945535a1aabf23ff213689ad72c..a755849fb56cda48bf5c8073cc9d897ad88dd83c 100644 (file)
@@ -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)
 {
index c3cc63f51c6e8cd7c4aa2d930985004064f12fc3..58cf515de78b53991de257e79388f2d29387f537 100644 (file)
@@ -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 <id>          print details on resource identified by <id>\n"), out);
-       fputs(_(" -N, --name <name>      print details on posix resource identified by <name>\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 <id>            System V resource identified by <id>\n"), out);
+       fputs(_(" -N, --name <name>        POSIX resource identified by <name>\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=<type> 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;