You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Joe Orton <jo...@redhat.com> on 2004/04/06 12:35:53 UTC

__attribute__((warn_unused_result))

It would be interesting to apply this new gcc 3.4 function attribute to
all functions which return an svn_error_t *; it might find some nice
bugs. e.g. this looks obvious enough from just doing
svn_error_create{,f}:

subversion/libsvn_fs/reps-strings.c: In function `rep_write':
subversion/libsvn_fs/reps-strings.c:966: warning: ignoring return value 
of function declared with attribute warn_unused_result

Index: subversion/libsvn_fs/reps-strings.c
===================================================================
--- subversion/libsvn_fs/reps-strings.c	(revision 9290)
+++ subversion/libsvn_fs/reps-strings.c	(working copy)
@@ -963,7 +963,7 @@
   SVN_ERR (svn_fs__bdb_read_rep (&rep, fs, rep_key, trail));
 
   if (! rep_is_mutable (rep, txn_id))
-    svn_error_createf
+    return svn_error_createf
       (SVN_ERR_FS_REP_NOT_MUTABLE, NULL,
        "Rep '%s' is not mutable", rep_key);
 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: __attribute__((warn_unused_result))

Posted by Branko Čibej <br...@xbc.nu>.
Joe Orton wrote:

>It would be interesting to apply this new gcc 3.4 function attribute to
>all functions which return an svn_error_t *; it might find some nice
>bugs. e.g. this looks obvious enough from just doing
>svn_error_create{,f}:
>
>subversion/libsvn_fs/reps-strings.c: In function `rep_write':
>subversion/libsvn_fs/reps-strings.c:966: warning: ignoring return value 
>of function declared with attribute warn_unused_result
>
>Index: subversion/libsvn_fs/reps-strings.c
>===================================================================
>--- subversion/libsvn_fs/reps-strings.c	(revision 9290)
>+++ subversion/libsvn_fs/reps-strings.c	(working copy)
>@@ -963,7 +963,7 @@
>   SVN_ERR (svn_fs__bdb_read_rep (&rep, fs, rep_key, trail));
> 
>   if (! rep_is_mutable (rep, txn_id))
>-    svn_error_createf
>+    return svn_error_createf
>       (SVN_ERR_FS_REP_NOT_MUTABLE, NULL,
>        "Rep '%s' is not mutable", rep_key);
> 
>

Heh, good catch! I wouldn't mind adding this to the sources, if it were
turned off by default (or possibly turned on by --enable-maintainer-mode
if configure detects GCC 3.4).


-- 
Brane Čibej   <br...@xbc.nu>   http://www.xbc.nu/brane/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org