* [PATCH] xfsprogs: mark some functions as noreturn
@ 2009-09-04 22:35 Eric Sandeen
2009-09-04 23:09 ` Christoph Hellwig
2009-09-08 14:39 ` [PATCH] xfsprogs: fix up the noreturn annotations Christoph Hellwig
0 siblings, 2 replies; 4+ messages in thread
From: Eric Sandeen @ 2009-09-04 22:35 UTC (permalink / raw)
To: xfs mailing list
Static checkers are a lot less noisy if they know certain
functions are noreturn.
Making this change removed about 50 errors from "clang" output.
(http://clang-analyzer.llvm.org) output.
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
---
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 69d91c5..ab8a7d9 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -27,7 +27,7 @@
*/
static void conflict(char opt, char *tab[], int oldidx, int newidx);
static void illegal(char *value, char *opt);
-static void reqval(char opt, char *tab[], int idx);
+static __attribute__((noreturn)) void reqval(char opt, char *tab[], int idx);
static void respec(char opt, char *tab[], int idx);
static void unknown(char opt, char *s);
static int ispow2(unsigned int i);
@@ -2464,7 +2464,7 @@ ispow2(
return (i & (i - 1)) == 0;
}
-static void
+static void __attribute__((noreturn))
reqval(
char opt,
char *tab[],
diff --git a/repair/err_protos.h b/repair/err_protos.h
index 556e9b9..6944950 100644
--- a/repair/err_protos.h
+++ b/repair/err_protos.h
@@ -16,7 +16,11 @@
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-void do_abort(char const *, ...); /* abort, internal error */
-void do_error(char const *, ...); /* abort, system error */
-void do_warn(char const *, ...); /* issue warning */
-void do_log(char const *, ...); /* issue log message */
+/* abort, internal error */
+void __attribute__((noreturn)) do_abort(char const *, ...);
+/* abort, system error */
+void __attribute__((noreturn)) do_error(char const *, ...);
+/* issue warning */
+void do_warn(char const *, ...);
+/* issue log message */
+void do_log(char const *, ...);
diff --git a/repair/xfs_repair.c b/repair/xfs_repair.c
index e9e5965..5dfc3c3 100644
--- a/repair/xfs_repair.c
+++ b/repair/xfs_repair.c
@@ -351,7 +351,7 @@ do_msg(int do_abort, char const *msg, va_list args)
}
}
-void
+void __attribute__((noreturn))
do_error(char const *msg, ...)
{
va_list args;
@@ -366,7 +366,7 @@ do_error(char const *msg, ...)
* like do_error, only the error is internal, no system
* error so no oserror processing
*/
-void
+void __attribute__((noreturn))
do_abort(char const *msg, ...)
{
va_list args;
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] xfsprogs: mark some functions as noreturn
2009-09-04 22:35 [PATCH] xfsprogs: mark some functions as noreturn Eric Sandeen
@ 2009-09-04 23:09 ` Christoph Hellwig
2009-09-08 14:39 ` [PATCH] xfsprogs: fix up the noreturn annotations Christoph Hellwig
1 sibling, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2009-09-04 23:09 UTC (permalink / raw)
To: Eric Sandeen; +Cc: xfs mailing list
On Fri, Sep 04, 2009 at 05:35:37PM -0500, Eric Sandeen wrote:
> Static checkers are a lot less noisy if they know certain
> functions are noreturn.
>
> Making this change removed about 50 errors from "clang" output.
> (http://clang-analyzer.llvm.org) output.
Not pretty but useful,
Reviewed-by: Christoph Hellwig <hch@lst.de>
> -void do_abort(char const *, ...); /* abort, internal error */
> -void do_error(char const *, ...); /* abort, system error */
> -void do_warn(char const *, ...); /* issue warning */
> -void do_log(char const *, ...); /* issue log message */
> +/* abort, internal error */
> +void __attribute__((noreturn)) do_abort(char const *, ...);
> +/* abort, system error */
> +void __attribute__((noreturn)) do_error(char const *, ...);
> +/* issue warning */
> +void do_warn(char const *, ...);
> +/* issue log message */
> +void do_log(char const *, ...);
It would be good to add the proper printflike attributes to these to
also get vararg typechecking.
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] xfsprogs: fix up the noreturn annotations
2009-09-04 22:35 [PATCH] xfsprogs: mark some functions as noreturn Eric Sandeen
2009-09-04 23:09 ` Christoph Hellwig
@ 2009-09-08 14:39 ` Christoph Hellwig
2009-09-09 17:16 ` Eric Sandeen
1 sibling, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2009-09-08 14:39 UTC (permalink / raw)
To: Eric Sandeen; +Cc: xfs mailing list
The usage function in mkfs needs a noreturn annotation too, otherwise
gcc will complain, similarly the do_msg function in repair would need
it if do_abort is set, but because conditional annotations aren't
possible just clean this area up an inline the do_msg function into
it's callers.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Index: xfsprogs-dev/mkfs/xfs_mkfs.c
===================================================================
--- xfsprogs-dev.orig/mkfs/xfs_mkfs.c 2009-09-08 11:33:17.892004074 -0300
+++ xfsprogs-dev/mkfs/xfs_mkfs.c 2009-09-08 11:33:26.993004077 -0300
@@ -27,6 +27,7 @@
*/
static void conflict(char opt, char *tab[], int oldidx, int newidx);
static void illegal(char *value, char *opt);
+static __attribute__((noreturn)) void usage (void);
static __attribute__((noreturn)) void reqval(char opt, char *tab[], int idx);
static void respec(char opt, char *tab[], int idx);
static void unknown(char opt, char *s);
@@ -2554,7 +2555,7 @@ cvtnum(
return -1LL;
}
-void
+static void __attribute__((noreturn))
usage( void )
{
fprintf(stderr, _("Usage: %s\n\
Index: xfsprogs-dev/mkfs/xfs_mkfs.h
===================================================================
--- xfsprogs-dev.orig/mkfs/xfs_mkfs.h 2009-09-08 11:33:17.904015867 -0300
+++ xfsprogs-dev/mkfs/xfs_mkfs.h 2009-09-08 11:33:26.993004077 -0300
@@ -68,7 +68,6 @@
/* xfs_mkfs.c */
-extern void usage (void);
extern int isdigits (char *str);
extern long long cvtnum (unsigned int blocksize,
unsigned int sectorsize, char *s);
Index: xfsprogs-dev/repair/xfs_repair.c
===================================================================
--- xfsprogs-dev.orig/repair/xfs_repair.c 2009-09-08 11:33:31.211278768 -0300
+++ xfsprogs-dev/repair/xfs_repair.c 2009-09-08 11:34:30.158256533 -0300
@@ -339,18 +339,6 @@ process_args(int argc, char **argv)
usage();
}
-void
-do_msg(int do_abort, char const *msg, va_list args)
-{
- vfprintf(stderr, msg, args);
-
- if (do_abort) {
- if (dumpcore)
- abort();
- exit(1);
- }
-}
-
void __attribute__((noreturn))
do_error(char const *msg, ...)
{
@@ -359,7 +347,10 @@ do_error(char const *msg, ...)
fprintf(stderr, _("\nfatal error -- "));
va_start(args, msg);
- do_msg(1, msg, args);
+ vfprintf(stderr, msg, args);
+ if (dumpcore)
+ abort();
+ exit(1);
}
/*
@@ -372,7 +363,10 @@ do_abort(char const *msg, ...)
va_list args;
va_start(args, msg);
- do_msg(1, msg, args);
+ vfprintf(stderr, msg, args);
+ if (dumpcore)
+ abort();
+ exit(1);
}
void
@@ -383,7 +377,7 @@ do_warn(char const *msg, ...)
fs_is_dirty = 1;
va_start(args, msg);
- do_msg(0, msg, args);
+ vfprintf(stderr, msg, args);
va_end(args);
}
@@ -395,7 +389,7 @@ do_log(char const *msg, ...)
va_list args;
va_start(args, msg);
- do_msg(0, msg, args);
+ vfprintf(stderr, msg, args);
va_end(args);
}
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] xfsprogs: fix up the noreturn annotations
2009-09-08 14:39 ` [PATCH] xfsprogs: fix up the noreturn annotations Christoph Hellwig
@ 2009-09-09 17:16 ` Eric Sandeen
0 siblings, 0 replies; 4+ messages in thread
From: Eric Sandeen @ 2009-09-09 17:16 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: xfs mailing list
Christoph Hellwig wrote:
> The usage function in mkfs needs a noreturn annotation too, otherwise
> gcc will complain, similarly the do_msg function in repair would need
> it if do_abort is set, but because conditional annotations aren't
> possible just clean this area up an inline the do_msg function into
> it's callers.
>
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Eric Sandeen <sandeen@sandeen.net>
> Index: xfsprogs-dev/mkfs/xfs_mkfs.c
> ===================================================================
> --- xfsprogs-dev.orig/mkfs/xfs_mkfs.c 2009-09-08 11:33:17.892004074 -0300
> +++ xfsprogs-dev/mkfs/xfs_mkfs.c 2009-09-08 11:33:26.993004077 -0300
> @@ -27,6 +27,7 @@
> */
> static void conflict(char opt, char *tab[], int oldidx, int newidx);
> static void illegal(char *value, char *opt);
> +static __attribute__((noreturn)) void usage (void);
> static __attribute__((noreturn)) void reqval(char opt, char *tab[], int idx);
> static void respec(char opt, char *tab[], int idx);
> static void unknown(char opt, char *s);
> @@ -2554,7 +2555,7 @@ cvtnum(
> return -1LL;
> }
>
> -void
> +static void __attribute__((noreturn))
> usage( void )
> {
> fprintf(stderr, _("Usage: %s\n\
> Index: xfsprogs-dev/mkfs/xfs_mkfs.h
> ===================================================================
> --- xfsprogs-dev.orig/mkfs/xfs_mkfs.h 2009-09-08 11:33:17.904015867 -0300
> +++ xfsprogs-dev/mkfs/xfs_mkfs.h 2009-09-08 11:33:26.993004077 -0300
> @@ -68,7 +68,6 @@
>
>
> /* xfs_mkfs.c */
> -extern void usage (void);
> extern int isdigits (char *str);
> extern long long cvtnum (unsigned int blocksize,
> unsigned int sectorsize, char *s);
> Index: xfsprogs-dev/repair/xfs_repair.c
> ===================================================================
> --- xfsprogs-dev.orig/repair/xfs_repair.c 2009-09-08 11:33:31.211278768 -0300
> +++ xfsprogs-dev/repair/xfs_repair.c 2009-09-08 11:34:30.158256533 -0300
> @@ -339,18 +339,6 @@ process_args(int argc, char **argv)
> usage();
> }
>
> -void
> -do_msg(int do_abort, char const *msg, va_list args)
> -{
> - vfprintf(stderr, msg, args);
> -
> - if (do_abort) {
> - if (dumpcore)
> - abort();
> - exit(1);
> - }
> -}
> -
> void __attribute__((noreturn))
> do_error(char const *msg, ...)
> {
> @@ -359,7 +347,10 @@ do_error(char const *msg, ...)
> fprintf(stderr, _("\nfatal error -- "));
>
> va_start(args, msg);
> - do_msg(1, msg, args);
> + vfprintf(stderr, msg, args);
> + if (dumpcore)
> + abort();
> + exit(1);
> }
>
> /*
> @@ -372,7 +363,10 @@ do_abort(char const *msg, ...)
> va_list args;
>
> va_start(args, msg);
> - do_msg(1, msg, args);
> + vfprintf(stderr, msg, args);
> + if (dumpcore)
> + abort();
> + exit(1);
> }
>
> void
> @@ -383,7 +377,7 @@ do_warn(char const *msg, ...)
> fs_is_dirty = 1;
>
> va_start(args, msg);
> - do_msg(0, msg, args);
> + vfprintf(stderr, msg, args);
> va_end(args);
> }
>
> @@ -395,7 +389,7 @@ do_log(char const *msg, ...)
> va_list args;
>
> va_start(args, msg);
> - do_msg(0, msg, args);
> + vfprintf(stderr, msg, args);
> va_end(args);
> }
>
>
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs
>
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-09-09 17:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-04 22:35 [PATCH] xfsprogs: mark some functions as noreturn Eric Sandeen
2009-09-04 23:09 ` Christoph Hellwig
2009-09-08 14:39 ` [PATCH] xfsprogs: fix up the noreturn annotations Christoph Hellwig
2009-09-09 17:16 ` Eric Sandeen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox