[glib: 1/3] gtestutils: Drop unnecessary NULL check




commit 065dea99f4c78695391c50bbd1c365b1628a5286
Author: Philip Withnall <pwithnall endlessos org>
Date:   Tue Nov 17 10:31:59 2020 +0000

    gtestutils: Drop unnecessary NULL check
    
    The macro wrapper to `g_assertion_message_cmpstrv()` makes sure that
    neither array is `NULL`, so there’s no need for a second `NULL` check.
    Additionally, this check happens after the arrays have already been
    dereferenced, at which point the program would have crashed if the
    arrays were `NULL`.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>
    
    Coverity CID: #1436406, #1436407

 glib/gtestutils.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/glib/gtestutils.c b/glib/gtestutils.c
index 1bc6aa2f3..d48368830 100644
--- a/glib/gtestutils.c
+++ b/glib/gtestutils.c
@@ -3055,8 +3055,8 @@ g_assertion_message_cmpstrv (const char         *domain,
   const char *s1 = arg1[first_wrong_idx], *s2 = arg2[first_wrong_idx];
   char *a1, *a2, *s, *t1 = NULL, *t2 = NULL;
 
-  a1 = arg1 ? g_strconcat ("\"", t1 = g_strescape (s1, NULL), "\"", NULL) : g_strdup ("NULL");
-  a2 = arg2 ? g_strconcat ("\"", t2 = g_strescape (s2, NULL), "\"", NULL) : g_strdup ("NULL");
+  a1 = g_strconcat ("\"", t1 = g_strescape (s1, NULL), "\"", NULL);
+  a2 = g_strconcat ("\"", t2 = g_strescape (s2, NULL), "\"", NULL);
   g_free (t1);
   g_free (t2);
   s = g_strdup_printf ("assertion failed (%s): first differing element at index %" G_GSIZE_FORMAT ": %s does 
not equal %s",


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]