changeset 24721:f26c5320e858

avoid comparison to NULL * mexproto.h (mxAssert): Use "if (msg && msg[0])" instead of "if (msg != NULL && msg[0] != '\0')".
author John W. Eaton <jwe@octave.org>
date Sat, 10 Feb 2018 06:37:16 -0500
parents 48f22c5b22aa
children af6c1ed60581
files libinterp/corefcn/mexproto.h
diffstat 1 files changed, 18 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/mexproto.h	Fri Feb 09 19:20:53 2018 +0100
+++ b/libinterp/corefcn/mexproto.h	Sat Feb 10 06:37:16 2018 -0500
@@ -302,14 +302,16 @@
     {                                                                   \
       if (! (expr))                                                     \
         {                                                               \
-          if (msg != NULL && msg[0] != '\0')                            \
-            mexErrMsgIdAndTxt ("Octave:MEX",                            \
-                               "Assertion failed: %s, at line %d of file \"%s\".\n%s\n", \
-                               #expr, __LINE__, __FILE__, msg);         \
+          if (msg && msg[0])                                            \
+            mexErrMsgIdAndTxt                                           \
+              ("Octave:MEX",                                            \
+               "Assertion failed: %s, at line %d of file \"%s\".\n%s\n", \
+               #expr, __LINE__, __FILE__, msg);                         \
           else                                                          \
-            mexErrMsgIdAndTxt ("Octave:MEX",                            \
-                               "Assertion failed: %s, at line %d of file \"%s\".\n", \
-                               #expr, __LINE__, __FILE__);              \
+            mexErrMsgIdAndTxt                                           \
+              ("Octave:MEX",                                            \
+               "Assertion failed: %s, at line %d of file \"%s\".\n",    \
+               #expr, __LINE__, __FILE__);                              \
         }                                                               \
     }                                                                   \
   while (0)
@@ -319,14 +321,16 @@
     {                                                                   \
       if (! (expr))                                                     \
         {                                                               \
-          if (msg != NULL && msg[0] != '\0')                            \
-            mexErrMsgIdAndTxt ("Octave:MEX",                            \
-                               "Assertion failed at line %d of file \"%s\".\n%s\n", \
-                               __LINE__, __FILE__, msg);                \
+          if (msg && msg[0])                                            \
+            mexErrMsgIdAndTxt                                           \
+              ("Octave:MEX",                                            \
+               "Assertion failed at line %d of file \"%s\".\n%s\n",     \
+               __LINE__, __FILE__, msg);                                \
           else                                                          \
-            mexErrMsgIdAndTxt ("Octave:MEX",                            \
-                               "Assertion failed at line %d of file \"%s\".\n", \
-                               __LINE__, __FILE__);                     \
+            mexErrMsgIdAndTxt                                           \
+              ("Octave:MEX",                                            \
+               "Assertion failed at line %d of file \"%s\".\n",         \
+               __LINE__, __FILE__);                                     \
         }                                                               \
     }                                                                   \
   while (0)