logo

utils-std

Collection of commonly available Unix tools
commit: 0c732a596fde2caa0e3eff2469bf2c3f3ec015c9
parent 2e78667cc401501e4b6729ff0f41867d3167123a
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Mon,  1 Apr 2024 08:26:26 +0200

cmd/*.c: Add static to non-main functions

Diffstat:

Mcmd/cat.c4++--
Mcmd/date.c2+-
Mcmd/env.c5+++--
Mcmd/id.c8++++----
Mcmd/nproc.c2+-
Mcmd/realpath.c2+-
Mcmd/rm.c2+-
Mcmd/rmdir.c2+-
Mcmd/strings.c6+++---
Mcmd/time.c2+-
10 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/cmd/cat.c b/cmd/cat.c @@ -12,7 +12,7 @@ #include <string.h> /* strerror(), strncmp() */ #include <unistd.h> /* read(), write(), close() */ -int +static int concat(int fd, const char *fdname) { ssize_t c; @@ -41,7 +41,7 @@ concat(int fd, const char *fdname) } #ifdef HAS_SPLICE -int +static int fd_copy(int fd, const char *fdname) { ssize_t c = 0; diff --git a/cmd/date.c b/cmd/date.c @@ -14,7 +14,7 @@ #include <time.h> /* time, localtime, tm, strftime, strptime */ #include <unistd.h> /* getopt(), optarg, optind */ -void +static void usage() { fprintf(stderr, "date [-uR] [-d datetime] [+format]\n"); diff --git a/cmd/env.c b/cmd/env.c @@ -14,7 +14,8 @@ extern char **environ; char *envclear[1]; -int export() +static int +export() { int i = 0; @@ -30,7 +31,7 @@ int export() return 0; } -void +static void usage() { fprintf(stderr, "env [-i] [-u key | --unset=key] [key=value ...] [command [args]]\n"); diff --git a/cmd/id.c b/cmd/id.c @@ -112,7 +112,7 @@ list_groups(struct passwd *pw, int ngroups, gid_t *groups) return 0; } -int +static int print_gid(char *field, struct group *gr, gid_t gid) { if(gr && gr->gr_name) @@ -135,7 +135,7 @@ print_gid(char *field, struct group *gr, gid_t gid) } } -int +static int print_uid(char *field, struct passwd *pw, uid_t uid) { if(pw && pw->pw_name) @@ -158,7 +158,7 @@ print_uid(char *field, struct passwd *pw, uid_t uid) } } -void +static void safe_getpwuid(uid_t uid, struct passwd *res) { struct passwd *pw = getpwuid(uid); @@ -177,7 +177,7 @@ enum id_modes ID_UID, }; -void +static void usage() { fprintf(stderr, "Usage: id [-Ggu] [-nr] [user]\n"); diff --git a/cmd/nproc.c b/cmd/nproc.c @@ -8,7 +8,7 @@ #include <stdio.h> // printf #include <unistd.h> // sysconf, getopt, opt* -void +static void usage() { fprintf(stderr, "Usage: nproc [-a]\n"); diff --git a/cmd/realpath.c b/cmd/realpath.c @@ -13,7 +13,7 @@ #include <string.h> // strncmp(), strnlen, strerror #include <unistd.h> // getopt -void +static void usage() { fprintf(stderr, "Usage: realpath [-E|-e] path\n"); diff --git a/cmd/rm.c b/cmd/rm.c @@ -229,7 +229,7 @@ do_unlinkat(int fd, char *name, char *acc_path) return err; } -void +static void usage() { fprintf(stderr, "Usage: rm [-firRv] [files ...]\n"); diff --git a/cmd/rmdir.c b/cmd/rmdir.c @@ -10,7 +10,7 @@ #include <string.h> // strerror, strrchr #include <unistd.h> // getopt, rmdir -void +static void usage() { fprintf(stderr, "Usage: rmdir [-pv] directory...\n"); diff --git a/cmd/strings.c b/cmd/strings.c @@ -16,7 +16,7 @@ size_t opt_min_strlen = 4; char *opt_offset_format = NULL; -int +static int print_string(char *buffer, size_t offset) { int ret = 0; @@ -43,7 +43,7 @@ print_string(char *buffer, size_t offset) } } -int +static int concat(int fd, const char *fdname) { ssize_t c; @@ -97,7 +97,7 @@ concat(int fd, const char *fdname) return 0; } -void +static void usage() { fprintf(stderr, "strings: [-a] [-t format] [-n number] [file...]\n"); diff --git a/cmd/time.c b/cmd/time.c @@ -10,7 +10,7 @@ #include <sys/wait.h> // waitpid #include <unistd.h> // sysconf, fork, execvp, getopt -void +static void usage() { fprintf(stderr, "Usage: time command [argument ...]\n");