Fix checkpatch warnings

This commit is contained in:
Arun Prakash Jana 2018-07-08 21:32:26 +05:30
parent 054465c00d
commit 9995facfb9
No known key found for this signature in database
GPG key ID: A75979F35C080412

29
nnn.c
View file

@ -213,7 +213,7 @@ typedef struct entry {
blkcnt_t blocks; /* number of 512B blocks allocated */ blkcnt_t blocks; /* number of 512B blocks allocated */
mode_t mode; mode_t mode;
uint nlen; /* Length of file name; can be uchar (< NAME_MAX + 1) */ uint nlen; /* Length of file name; can be uchar (< NAME_MAX + 1) */
}__attribute__ ((packed, aligned(_ALIGNMENT))) *pEntry; } __attribute__ ((packed, aligned(_ALIGNMENT))) *pEntry;
/* Bookmark */ /* Bookmark */
typedef struct { typedef struct {
@ -1307,13 +1307,12 @@ mkpath(char *dir, char *name, char *out, size_t n)
/* Handle absolute path */ /* Handle absolute path */
if (name[0] == '/') if (name[0] == '/')
return xstrlcpy(out, name, n); return xstrlcpy(out, name, n);
else {
/* Handle root case */ /* Handle root case */
if (istopdir(dir)) if (istopdir(dir))
len = 1; len = 1;
else else
len = xstrlcpy(out, dir, n); len = xstrlcpy(out, dir, n);
}
out[len - 1] = '/'; out[len - 1] = '/';
return (xstrlcpy(out + len, name, n - len) + len); return (xstrlcpy(out + len, name, n - len) + len);
@ -1734,6 +1733,7 @@ static char *
xgetpwuid(uid_t uid) xgetpwuid(uid_t uid)
{ {
struct passwd *pwd = getpwuid(uid); struct passwd *pwd = getpwuid(uid);
if (!pwd) if (!pwd)
return utils[UNKNOWN]; return utils[UNKNOWN];
@ -1744,6 +1744,7 @@ static char *
xgetgrgid(gid_t gid) xgetgrgid(gid_t gid)
{ {
struct group *grp = getgrgid(gid); struct group *grp = getgrgid(gid);
if (!grp) if (!grp)
return utils[UNKNOWN]; return utils[UNKNOWN];
@ -2758,13 +2759,11 @@ nochange:
if (sel == SEL_CDBEGIN) if (sel == SEL_CDBEGIN)
dir = ipath; dir = ipath;
if (!xdiraccess(dir)) { if (!xdiraccess(dir))
goto nochange; goto nochange;
}
if (strcmp(path, dir) == 0) { if (strcmp(path, dir) == 0)
break; break;
}
/* Save last working directory */ /* Save last working directory */
xstrlcpy(lastdir, path, PATH_MAX); xstrlcpy(lastdir, path, PATH_MAX);
@ -3051,8 +3050,7 @@ nochange:
else else
spawn(copier, pcopybuf, NULL, NULL, F_NOTRACE); spawn(copier, pcopybuf, NULL, NULL, F_NOTRACE);
if (ncp) /* Some files cherry picked */ if (ncp) { /* Some files cherry picked */
{
snprintf(newpath, PATH_MAX, "%d files copied", ncp); snprintf(newpath, PATH_MAX, "%d files copied", ncp);
printmsg(newpath); printmsg(newpath);
} }
@ -3232,6 +3230,7 @@ nochange:
if (tmp) { if (tmp) {
if (getenv("NNN_MULTISCRIPT")) { if (getenv("NNN_MULTISCRIPT")) {
size_t _len = xstrlcpy(newpath, tmp, PATH_MAX); size_t _len = xstrlcpy(newpath, tmp, PATH_MAX);
tmp = xreadline(NULL, "script suffix: "); tmp = xreadline(NULL, "script suffix: ");
if (tmp && tmp[0]) if (tmp && tmp[0])
xstrlcpy(newpath + _len - 1, tmp, PATH_MAX - _len); xstrlcpy(newpath + _len - 1, tmp, PATH_MAX - _len);
@ -3240,6 +3239,7 @@ nochange:
} }
char *curfile = NULL; char *curfile = NULL;
if (ndents > 0) if (ndents > 0)
curfile = dents[cur].name; curfile = dents[cur].name;
@ -3452,6 +3452,7 @@ main(int argc, char *argv[])
cfg.noxdisplay = 1; cfg.noxdisplay = 1;
struct passwd *pass = getpwuid(getuid()); struct passwd *pass = getpwuid(getuid());
xstrlcpy(g_cppath, "/tmp/nnncp", 11); xstrlcpy(g_cppath, "/tmp/nnncp", 11);
xstrlcpy(g_cppath + 10, pass->pw_name, 33); xstrlcpy(g_cppath + 10, pass->pw_name, 33);
} }