diff options
author | Arun Prakash Jana <engineerarun@gmail.com> | 2020-02-14 06:42:30 +0530 |
---|---|---|
committer | Arun Prakash Jana <engineerarun@gmail.com> | 2020-02-14 06:42:30 +0530 |
commit | 928f325a7439193b11d34117f648b2cd846ea1ea (patch) | |
tree | 14b8d609e41b5fdf46ccbd7e138552ef3b1ef18e /src/nnn.c | |
parent | ed616cf74612e6ee66b0837089ece40df6663c8f (diff) | |
download | nnn-928f325a7439193b11d34117f648b2cd846ea1ea.tar.gz |
Use atoi from lib, use attribute for unused
Diffstat (limited to 'src/nnn.c')
-rw-r--r-- | src/nnn.c | 40 |
1 files changed, 12 insertions, 28 deletions
@@ -643,6 +643,12 @@ static haiku_nm_h haiku_hnd; #define xisdigit(c) ((unsigned int) (c) - '0' <= 9) #define xerror() perror(xitoa(__LINE__)) +#ifdef __GNUC__ +#define UNUSED(x) UNUSED_##x __attribute__((__unused__)) +#else +#define UNUSED(x) UNUSED_##x +#endif /* __GNUC__ */ + /* Forward declarations */ static void redraw(char *path); static int spawn(char *file, char *arg1, char *arg2, const char *dir, uchar flag); @@ -656,28 +662,11 @@ static void plugscript(const char *plugin, char *newpath, uchar flags); /* Functions */ -static void sigint_handler(int sig) +static void sigint_handler(int UNUSED(sig)) { - (void) sig; - g_states |= STATE_INTERRUPTED; } -static uint xatoi(const char *str) -{ - int val = 0; - - if (!str) - return 0; - - while (xisdigit(*str)) { - val = val * 10 + (*str - '0'); - ++str; - } - - return val; -} - static char *xitoa(uint val) { static char ascbuf[32] = {0}; @@ -4143,11 +4132,8 @@ static void launch_app(const char *path, char *newpath) spawn(tmp, "0", NULL, path, r); } -static int sum_bsize(const char *fpath, const struct stat *sb, int typeflag, struct FTW *ftwbuf) +static int sum_bsize(const char *UNUSED(fpath), const struct stat *sb, int typeflag, struct FTW *UNUSED(ftwbuf)) { - (void) fpath; - (void) ftwbuf; - if (sb->st_blocks && (typeflag == FTW_F || typeflag == FTW_D)) ent_blocks += sb->st_blocks; @@ -4155,11 +4141,8 @@ static int sum_bsize(const char *fpath, const struct stat *sb, int typeflag, str return 0; } -static int sum_asize(const char *fpath, const struct stat *sb, int typeflag, struct FTW *ftwbuf) +static int sum_asize(const char *UNUSED(fpath), const struct stat *sb, int typeflag, struct FTW *UNUSED(ftwbuf)) { - (void) fpath; - (void) ftwbuf; - if (sb->st_size && (typeflag == FTW_F || typeflag == FTW_D)) ent_blocks += sb->st_size; @@ -6520,7 +6503,7 @@ int main(int argc, char *argv[]) session = optarg; break; case 't': - idletimeout = xatoi(optarg); + idletimeout = atoi(optarg); break; case 'v': namecmpfn = &xstrverscasecmp; @@ -6695,7 +6678,8 @@ int main(int argc, char *argv[]) #endif /* Set nnn nesting level */ - setenv(env_cfg[NNNLVL], xitoa(xatoi(getenv(env_cfg[NNNLVL])) + 1), 1); + arg = getenv(env_cfg[NNNLVL]); + setenv(env_cfg[NNNLVL], xitoa((arg ? atoi(arg) : 0) + 1), 1); if (xgetenv_set(env_cfg[NNN_TRASH])) cfg.trash = 1; |