]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
gfs2: Return bool from gfs2_assert functions
authorAndreas Gruenbacher <agruenba@redhat.com>
Thu, 23 Jan 2020 18:36:21 +0000 (19:36 +0100)
committerBob Peterson <rpeterso@redhat.com>
Mon, 10 Feb 2020 13:39:47 +0000 (07:39 -0600)
The gfs2_assert functions only print messages when the filesystem hasn't been
withdrawn yet, and they indicate whether or not they've printed something in
their return value.  However, none of the callers use that information, so
simply return whether or not the assert has failed.

(The gfs2_assert functions are still backwards; they return false when an
assertion is true.)

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
fs/gfs2/util.c
fs/gfs2/util.h

index 698eb595243899bec5d06a5a0fbf145ac48648bf..ec8e8c5ce8483302f17f3613f28444607b2c209e 100644 (file)
@@ -84,37 +84,30 @@ int gfs2_withdraw(struct gfs2_sbd *sdp)
 
 /**
  * gfs2_assert_withdraw_i - Cause the machine to withdraw if @assertion is false
- * Returns: -1 if this call withdrew the machine,
- *          -2 if it was already withdrawn
  */
 
-int gfs2_assert_withdraw_i(struct gfs2_sbd *sdp, char *assertion,
-                          const char *function, char *file, unsigned int line)
+void gfs2_assert_withdraw_i(struct gfs2_sbd *sdp, char *assertion,
+                           const char *function, char *file, unsigned int line)
 {
-       int me;
-
        gfs2_lm(sdp,
                "fatal: assertion \"%s\" failed\n"
                "   function = %s, file = %s, line = %u\n",
                assertion, function, file, line);
-       me = gfs2_withdraw(sdp);
+       gfs2_withdraw(sdp);
        dump_stack();
-       return (me) ? -1 : -2;
 }
 
 /**
  * gfs2_assert_warn_i - Print a message to the console if @assertion is false
- * Returns: -1 if we printed something
- *          -2 if we didn't
  */
 
-int gfs2_assert_warn_i(struct gfs2_sbd *sdp, char *assertion,
-                      const char *function, char *file, unsigned int line)
+void gfs2_assert_warn_i(struct gfs2_sbd *sdp, char *assertion,
+                       const char *function, char *file, unsigned int line)
 {
        if (time_before(jiffies,
                        sdp->sd_last_warning +
                        gfs2_tune_get(sdp, gt_complain_secs) * HZ))
-               return -2;
+               return;
 
        if (sdp->sd_args.ar_errors == GFS2_ERRORS_WITHDRAW)
                fs_warn(sdp, "warning: assertion \"%s\" failed at function = %s, file = %s, line = %u\n",
@@ -132,8 +125,6 @@ int gfs2_assert_warn_i(struct gfs2_sbd *sdp, char *assertion,
                      sdp->sd_fsname, function, file, line);
 
        sdp->sd_last_warning = jiffies;
-
-       return -1;
 }
 
 /**
index 93e089327216f424873775a5c8c791b7fe2f538b..572399e75ce660f9ab50093b114259dd8814163b 100644 (file)
@@ -36,21 +36,29 @@ do { \
 } while (0)
 
 
-int gfs2_assert_withdraw_i(struct gfs2_sbd *sdp, char *assertion,
-                          const char *function, char *file, unsigned int line);
+void gfs2_assert_withdraw_i(struct gfs2_sbd *sdp, char *assertion,
+                           const char *function, char *file, unsigned int line);
 
 #define gfs2_assert_withdraw(sdp, assertion) \
-((likely(assertion)) ? 0 : gfs2_assert_withdraw_i((sdp), #assertion, \
-                                       __func__, __FILE__, __LINE__))
+       ({ \
+               bool _bool = (assertion); \
+               if (unlikely(!_bool)) \
+                       gfs2_assert_withdraw_i((sdp), #assertion, \
+                                       __func__, __FILE__, __LINE__); \
+               !_bool; \
+       })
 
-
-int gfs2_assert_warn_i(struct gfs2_sbd *sdp, char *assertion,
-                      const char *function, char *file, unsigned int line);
+void gfs2_assert_warn_i(struct gfs2_sbd *sdp, char *assertion,
+                       const char *function, char *file, unsigned int line);
 
 #define gfs2_assert_warn(sdp, assertion) \
-((likely(assertion)) ? 0 : gfs2_assert_warn_i((sdp), #assertion, \
-                                       __func__, __FILE__, __LINE__))
-
+       ({ \
+               bool _bool = (assertion); \
+               if (unlikely(!_bool)) \
+                       gfs2_assert_warn_i((sdp), #assertion, \
+                                       __func__, __FILE__, __LINE__); \
+               !_bool; \
+       })
 
 void gfs2_consist_i(struct gfs2_sbd *sdp,
                    const char *function, char *file, unsigned int line);