Discussion:
Don't declare main() in fsck, fsck_msdos, fsdb, ncheck_ffs
Michal Mazurek
2016-01-02 16:30:27 UTC
Permalink
main() does not need to be declared.

Also mark usage() as __dead in fsck_msdos and fsdb.


Index: fsck/fsck.c
===================================================================
RCS file: /cvs/src/sbin/fsck/fsck.c,v
retrieving revision 1.38
diff -u -p -r1.38 fsck.c
--- fsck/fsck.c 23 Nov 2015 19:19:29 -0000 1.38
+++ fsck/fsck.c 2 Jan 2016 16:24:39 -0000
@@ -70,8 +70,6 @@ static int maxrun;
static char *options;
static int flags;

-int main(int, char *[]);
-
static int checkfs(const char *, const char *, const char *, void *, pid_t *);
static int selected(const char *);
static void addoption(char *);
Index: fsck_msdos/main.c
===================================================================
RCS file: /cvs/src/sbin/fsck_msdos/main.c,v
retrieving revision 1.22
diff -u -p -r1.22 main.c
--- fsck_msdos/main.c 23 Nov 2015 19:19:30 -0000 1.22
+++ fsck_msdos/main.c 2 Jan 2016 16:24:39 -0000
@@ -43,10 +43,9 @@ int alwaysyes; /* assume "yes" for all
int preen; /* set when preening */
int rdonly; /* device is opened read only (supersedes above) */

-static void usage(void);
-int main(int, char **);
+__dead static void usage(void);

-static void
+__dead static void
usage(void)
{
errexit("usage: fsck_msdos [-fnpy] filesystem\n");
Index: fsdb/fsdb.c
===================================================================
RCS file: /cvs/src/sbin/fsdb/fsdb.c,v
retrieving revision 1.29
diff -u -p -r1.29 fsdb.c
--- fsdb/fsdb.c 20 Jan 2015 18:22:21 -0000 1.29
+++ fsdb/fsdb.c 2 Jan 2016 16:24:39 -0000
@@ -55,8 +55,7 @@

extern char *__progname; /* from crt0.o */

-int main(int, char *[]);
-static void usage(void);
+__dead static void usage(void);
static int cmdloop(void);
static int helpfn(int, char *[]);
static char *prompt(EditLine *);
@@ -70,7 +69,7 @@ int returntosingle = 0;
union dinode *curinode;
ino_t curinum;

-static void
+__dead static void
usage(void)
{
fprintf(stderr, "usage: %s [-d] -f fsname\n", __progname);
Index: ncheck_ffs/ncheck_ffs.c
===================================================================
RCS file: /cvs/src/sbin/ncheck_ffs/ncheck_ffs.c,v
retrieving revision 1.52
diff -u -p -r1.52 ncheck_ffs.c
--- ncheck_ffs/ncheck_ffs.c 23 Nov 2015 19:19:30 -0000 1.52
+++ ncheck_ffs/ncheck_ffs.c 2 Jan 2016 16:24:39 -0000
@@ -119,7 +119,6 @@ int matchino(const void *, const void *)
int matchcache(const void *, const void *);
void cacheino(ufsino_t, void *);
void *cached(ufsino_t);
-int main(int, char *[]);
char *rawname(char *);
void format_entry(const char *, struct direct *);
--
Michal Mazurek
Philip Guenther
2016-01-02 20:08:01 UTC
Permalink
Post by Michal Mazurek
main() does not need to be declared.
Out of curiosity, has someone positively confirmed that gcc3, like
gcc4, treats main as explicitly declared for the purposes of
-Werror-implicit-function-declaration?


Philip Guenther
Michal Mazurek
2016-01-26 15:43:44 UTC
Permalink
Post by Michal Mazurek
main() does not need to be declared.
Also mark usage() as __dead in fsck_msdos and fsdb.
This was never commited.

Below are just the diffs to remove the declaration of main():


Index: fsck.c
===================================================================
RCS file: /cvs/src/sbin/fsck/fsck.c,v
retrieving revision 1.38
diff -u -p -r1.38 fsck.c
--- fsck.c 23 Nov 2015 19:19:29 -0000 1.38
+++ fsck.c 26 Jan 2016 15:38:43 -0000
@@ -70,8 +70,6 @@ static int maxrun;
static char *options;
static int flags;

-int main(int, char *[]);
-
static int checkfs(const char *, const char *, const char *, void *, pid_t *);
static int selected(const char *);
static void addoption(char *);

Index: main.c
===================================================================
RCS file: /cvs/src/sbin/fsck_msdos/main.c,v
retrieving revision 1.22
diff -u -p -r1.22 main.c
--- main.c 23 Nov 2015 19:19:30 -0000 1.22
+++ main.c 26 Jan 2016 15:39:57 -0000
@@ -44,7 +44,6 @@ int preen; /* set when preening */
int rdonly; /* device is opened read only (supersedes above) */

static void usage(void);
-int main(int, char **);

static void
usage(void)

Index: fsdb.c
===================================================================
RCS file: /cvs/src/sbin/fsdb/fsdb.c,v
retrieving revision 1.29
diff -u -p -r1.29 fsdb.c
--- fsdb.c 20 Jan 2015 18:22:21 -0000 1.29
+++ fsdb.c 26 Jan 2016 15:40:29 -0000
@@ -55,7 +55,6 @@

extern char *__progname; /* from crt0.o */

-int main(int, char *[]);
static void usage(void);
static int cmdloop(void);
static int helpfn(int, char *[]);

Index: ncheck_ffs.c
===================================================================
RCS file: /cvs/src/sbin/ncheck_ffs/ncheck_ffs.c,v
retrieving revision 1.52
diff -u -p -r1.52 ncheck_ffs.c
--- ncheck_ffs.c 23 Nov 2015 19:19:30 -0000 1.52
+++ ncheck_ffs.c 26 Jan 2016 15:40:58 -0000
@@ -119,7 +119,6 @@ int matchino(const void *, const void *)
int matchcache(const void *, const void *);
void cacheino(ufsino_t, void *);
void *cached(ufsino_t);
-int main(int, char *[]);
char *rawname(char *);
void format_entry(const char *, struct direct *);
Post by Michal Mazurek
Index: fsck/fsck.c
===================================================================
RCS file: /cvs/src/sbin/fsck/fsck.c,v
retrieving revision 1.38
diff -u -p -r1.38 fsck.c
--- fsck/fsck.c 23 Nov 2015 19:19:29 -0000 1.38
+++ fsck/fsck.c 2 Jan 2016 16:24:39 -0000
@@ -70,8 +70,6 @@ static int maxrun;
static char *options;
static int flags;
-int main(int, char *[]);
-
static int checkfs(const char *, const char *, const char *, void *, pid_t *);
static int selected(const char *);
static void addoption(char *);
Index: fsck_msdos/main.c
===================================================================
RCS file: /cvs/src/sbin/fsck_msdos/main.c,v
retrieving revision 1.22
diff -u -p -r1.22 main.c
--- fsck_msdos/main.c 23 Nov 2015 19:19:30 -0000 1.22
+++ fsck_msdos/main.c 2 Jan 2016 16:24:39 -0000
@@ -43,10 +43,9 @@ int alwaysyes; /* assume "yes" for all
int preen; /* set when preening */
int rdonly; /* device is opened read only (supersedes above) */
-static void usage(void);
-int main(int, char **);
+__dead static void usage(void);
-static void
+__dead static void
usage(void)
{
errexit("usage: fsck_msdos [-fnpy] filesystem\n");
Index: fsdb/fsdb.c
===================================================================
RCS file: /cvs/src/sbin/fsdb/fsdb.c,v
retrieving revision 1.29
diff -u -p -r1.29 fsdb.c
--- fsdb/fsdb.c 20 Jan 2015 18:22:21 -0000 1.29
+++ fsdb/fsdb.c 2 Jan 2016 16:24:39 -0000
@@ -55,8 +55,7 @@
extern char *__progname; /* from crt0.o */
-int main(int, char *[]);
-static void usage(void);
+__dead static void usage(void);
static int cmdloop(void);
static int helpfn(int, char *[]);
static char *prompt(EditLine *);
@@ -70,7 +69,7 @@ int returntosingle = 0;
union dinode *curinode;
ino_t curinum;
-static void
+__dead static void
usage(void)
{
fprintf(stderr, "usage: %s [-d] -f fsname\n", __progname);
Index: ncheck_ffs/ncheck_ffs.c
===================================================================
RCS file: /cvs/src/sbin/ncheck_ffs/ncheck_ffs.c,v
retrieving revision 1.52
diff -u -p -r1.52 ncheck_ffs.c
--- ncheck_ffs/ncheck_ffs.c 23 Nov 2015 19:19:30 -0000 1.52
+++ ncheck_ffs/ncheck_ffs.c 2 Jan 2016 16:24:39 -0000
@@ -119,7 +119,6 @@ int matchino(const void *, const void *)
int matchcache(const void *, const void *);
void cacheino(ufsino_t, void *);
void *cached(ufsino_t);
-int main(int, char *[]);
char *rawname(char *);
void format_entry(const char *, struct direct *);
--
Michal Mazurek
--
Michal Mazurek
Loading...