Checkpatch fixes

This commit is contained in:
Arun Prakash Jana 2021-06-10 00:09:24 +05:30
parent 54b2eb51d5
commit cbbac4728b
No known key found for this signature in database
GPG key ID: A75979F35C080412
2 changed files with 25 additions and 21 deletions

View file

@ -281,7 +281,7 @@ nnn v3.1
- hover and connect by dir name (within config dir) - hover and connect by dir name (within config dir)
- move to next entry on current file delete - move to next entry on current file delete
- on single file copy/move, select the copied/moved file - on single file copy/move, select the copied/moved file
- option `-f` to to use readline history file (off by default) - option `-f` to use readline history file (off by default)
- use `s` in status bar to indicate selection in progress - use `s` in status bar to indicate selection in progress
- make var `O_NOMOUSE` to disable mouse support - make var `O_NOMOUSE` to disable mouse support
- do not store `NNN_TRASH` and `-Q` in config/session - do not store `NNN_TRASH` and `-Q` in config/session

View file

@ -448,7 +448,7 @@ static regex_t archive_re;
(sb->st_nlink <= 1 || test_set_bit((uint_t)sb->st_ino))) || node->fts_info & FTS_DP) (sb->st_nlink <= 1 || test_set_bit((uint_t)sb->st_ino))) || node->fts_info & FTS_DP)
static int threadbmp = -1; /* Has 1 in the bit position for idle threads */ static int threadbmp = -1; /* Has 1 in the bit position for idle threads */
static volatile int active_threads = 0; static volatile int active_threads;
static pthread_mutex_t running_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t running_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t hardlink_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t hardlink_mutex = PTHREAD_MUTEX_INITIALIZER;
static ulong_t *core_files; static ulong_t *core_files;
@ -696,7 +696,7 @@ static char mv[] = "mv -i";
#endif #endif
/* Archive commands */ /* Archive commands */
static const char *archive_cmd[] = {"atool -a", "bsdtar -acvf", "zip -r", "tar -acvf"}; static const char * const archive_cmd[] = {"atool -a", "bsdtar -acvf", "zip -r", "tar -acvf"};
/* Tokens used for path creation */ /* Tokens used for path creation */
#define TOK_SSN 0 #define TOK_SSN 0
@ -1030,13 +1030,15 @@ static char *xextension(const char *fname, size_t len)
} }
#ifndef NOUG #ifndef NOUG
/* One-shot cache for getpwuid/getgrgid. Returns the cached name if the /*
* One-shot cache for getpwuid/getgrgid. Returns the cached name if the
* provided uid is the same as the previous uid. Returns xitoa(guid) if * provided uid is the same as the previous uid. Returns xitoa(guid) if
* the guid is not found in the password database. */ * the guid is not found in the password database.
*/
static char *getpwname(uid_t uid) static char *getpwname(uid_t uid)
{ {
static uint_t uidcache = UINT_MAX; static uint_t uidcache = UINT_MAX;
static char *namecache = NULL; static char *namecache;
if (uidcache != uid) { if (uidcache != uid) {
struct passwd *pw = getpwuid(uid); struct passwd *pw = getpwuid(uid);
@ -1051,7 +1053,7 @@ static char *getpwname(uid_t uid)
static char *getgrname(gid_t gid) static char *getgrname(gid_t gid)
{ {
static uint_t gidcache = UINT_MAX; static uint_t gidcache = UINT_MAX;
static char *grpcache = NULL; static char *grpcache;
if (gidcache != gid) { if (gidcache != gid) {
struct group *gr = getgrgid(gid); struct group *gr = getgrgid(gid);
@ -3503,6 +3505,7 @@ static wchar_t *unescape(const char *str, uint_t maxcols)
if (len >= maxcols) { if (len >= maxcols) {
size_t lencount = maxcols; size_t lencount = maxcols;
while (len > maxcols) /* Reduce wide chars one by one till it fits */ while (len > maxcols) /* Reduce wide chars one by one till it fits */
len = wcswidth(wbuf, --lencount); len = wcswidth(wbuf, --lencount);
@ -4870,7 +4873,9 @@ static bool run_selected_plugin(char **path, const char *file, char *runfile, ch
exitcurses(); exitcurses();
if ((p = fork()) == 0) { // In child p = fork();
if (!p) { // In child
int wfd = open(g_pipepath, O_WRONLY | O_CLOEXEC); int wfd = open(g_pipepath, O_WRONLY | O_CLOEXEC);
if (wfd == -1) if (wfd == -1)
@ -5053,15 +5058,16 @@ static void *du_thread(void *p_data)
static void dirwalk(char *dir, char *path, int entnum, bool mountpoint) static void dirwalk(char *dir, char *path, int entnum, bool mountpoint)
{ {
/* Loop till any core is free */ /* Loop till any core is free */
while (active_threads == NUM_DU_THREADS){} while (active_threads == NUM_DU_THREADS);
if (g_state.interrupt) if (g_state.interrupt)
return; return;
pthread_mutex_lock(&running_mutex); pthread_mutex_lock(&running_mutex);
++active_threads;
int core = ffs(threadbmp) - 1; int core = ffs(threadbmp) - 1;
threadbmp &= ~(1 << core); threadbmp &= ~(1 << core);
++active_threads;
pthread_mutex_unlock(&running_mutex); pthread_mutex_unlock(&running_mutex);
xstrsncpy(core_data[core].path, path, PATH_MAX); xstrsncpy(core_data[core].path, path, PATH_MAX);
@ -5221,7 +5227,7 @@ static int dentfill(char *path, struct entry **ppdents)
if (ndents == total_dents) { if (ndents == total_dents) {
if (cfg.blkorder) if (cfg.blkorder)
while (active_threads) {} while (active_threads);
total_dents += ENTRY_INCR; total_dents += ENTRY_INCR;
*ppdents = xrealloc(*ppdents, total_dents * sizeof(**ppdents)); *ppdents = xrealloc(*ppdents, total_dents * sizeof(**ppdents));
@ -5351,7 +5357,7 @@ static int dentfill(char *path, struct entry **ppdents)
exit: exit:
if (cfg.blkorder) { if (cfg.blkorder) {
while (active_threads) {} while (active_threads);
attroff(COLOR_PAIR(cfg.curctx + 1)); attroff(COLOR_PAIR(cfg.curctx + 1));
for (int i = 0; i < NUM_DU_THREADS; ++i) { for (int i = 0; i < NUM_DU_THREADS; ++i) {
@ -5803,8 +5809,7 @@ static void statusbar(char *path)
addch(' '); addch(' ');
} }
#endif #endif
if (S_ISLNK(pent->mode)) if (S_ISLNK(pent->mode)) {
{
i = readlink(pent->name, g_buf, PATH_MAX); i = readlink(pent->name, g_buf, PATH_MAX);
addstr(coolsize(i >= 0 ? i : pent->size)); /* Show symlink size */ addstr(coolsize(i >= 0 ? i : pent->size)); /* Show symlink size */
@ -5822,8 +5827,7 @@ static void statusbar(char *path)
addstr(coolsize(pent->size)); addstr(coolsize(pent->size));
addch(' '); addch(' ');
addstr(ptr); addstr(ptr);
if (pent->flags & HARD_LINK) if (pent->flags & HARD_LINK) {
{
struct stat sb; struct stat sb;
if (stat(pent->name, &sb) != -1) { if (stat(pent->name, &sb) != -1) {