Project

General

Profile

Bug #6126

misc updates in ucbcmd/chown

Added by Richard PALO about 5 years ago. Updated about 5 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
-
Start date:
2015-08-15
Due date:
% Done:

0%

Estimated time:
Difficulty:
Medium
Tags:
needs-triage
Gerrit CR:

Description

The following patch cleans up building chown.c in ucbcmd by including missing headers
and function prototypes, as well as additional parens in the test for a 'while' loop.

richard@omnis:/home/richard/src/illumos-gate/usr/src/ucbcmd/chown$ git diff upstream .
diff --git a/usr/src/ucbcmd/chown/Makefile b/usr/src/ucbcmd/chown/Makefile
index 7c1ba6f..9074179 100644
--- a/usr/src/ucbcmd/chown/Makefile
+++ b/usr/src/ucbcmd/chown/Makefile
@@ -31,8 +31,6 @@ include ../Makefile.ucbcmd
 FILEMODE=      755

 CPPFLAGS += -D_FILE_OFFSET_BITS=64
-CERRWARN += -_gcc=-Wno-implicit-function-declaration
-CERRWARN += -_gcc=-Wno-parentheses
 LDFLAGS += $(MAPFILE.NGB:%=-M%)

 .KEEP_STATE:
diff --git a/usr/src/ucbcmd/chown/chown.c b/usr/src/ucbcmd/chown/chown.c
index 9567b1d..ab3132a 100644
--- a/usr/src/ucbcmd/chown/chown.c
+++ b/usr/src/ucbcmd/chown/chown.c
@@ -37,12 +37,10 @@
  * contributors.
  */

-#pragma ident  "%Z%%M% %I%     %E% SMI" 
-
 /*
  * chown [-fR] uid[.gid] file ...
  */
-
+#include <stdlib.h>
 #include <stdio.h>
 #include <ctype.h>
 #include <sys/types.h>
@@ -50,6 +48,7 @@
 #include <pwd.h>
 #include <dirent.h>
 #include <grp.h>
+#include <unistd.h>
 #include <errno.h>

 struct passwd *pwd;
@@ -60,7 +59,10 @@ int  status;
 int    fflag;
 int    rflag;

-void fatal(int, char *, char *);
+static void fatal(int, char *, char *);
+static int chownr(char *dir, uid_t uid, gid_t gid);
+static int isnumber(char *s);
+static int Perror(char *s);

 int
 main(int argc, char *argv[])
@@ -157,7 +159,7 @@ isnumber(char *s)
 {
        int c;

-       while (c = *s++)
+       while ((c = *s++))
                if (!isdigit(c))
                        return (0);
        return (1);

Files

chown.diff (2.93 KB) chown.diff updated patchset Richard PALO, 2015-08-15 09:13 PM

History

#1

Updated by Gary Mills about 5 years ago

I suppose the line:

while ((c = *s++))

would be better expressed as:

while ((c = *s++) != '\0')
#2

Updated by Richard PALO about 5 years ago

Yeah, I was working on lint suggestions (since I hadn't yet done that)... updated patchset linted & cstyled.
Still have the following lint message, though

"/home/richard/src/illumos-gate/proto/root_i386/usr/include/sys/dirent.h", line 124: warning: name declared but never used or defined: getdents64 in dirent.h(124) (E_NAME_DECL_NOT_USED_DEF2)

and am looking for suggestions other than adding

LINTFLAGS +=       -erroff=E_NAME_DECL_NOT_USED_DEF2

Also available in: Atom PDF