OSDN Git Service

Ensure non-void functions always return explicit values.
authorKeith Marshall <keith@users.osdn.me>
Sun, 21 Jun 2020 11:31:36 +0000 (12:31 +0100)
committerKeith Marshall <keith@users.osdn.me>
Sun, 21 Jun 2020 11:31:36 +0000 (12:31 +0100)
ChangeLog
src/dmhguix.cpp
src/guimain.cpp

index b41bfe3..ba51a7c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2020-06-21  Keith Marshall  <keith@users.osdn.me>
+
+       Ensure non-void functions always return explicit values.
+
+       * src/guimain.cpp (WinMain): Remove explicit EXIT_FAILURE returns from
+       individual exception handlers; relocate it to the default execution
+       path, to which all such handlers will fall through.
+
+       * src/dmhguix.cpp (dmhTypeGUI::notify) [DMH_COMPILE_DIGEST]: Return
+       number of bytes added to message queue; fall through, to return zero,
+       on failure to extend the queue.
+
 2020-06-20  Keith Marshall  <keith@users.osdn.me>
 
        Simplify numeric argument interpreter function.
index 70a5e2f..526afcb 100644 (file)
@@ -3,8 +3,8 @@
  *
  * $Id$
  *
- * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
- * Copyright (C) 2009-2013, MinGW.org Project
+ * Written by Keith Marshall <keith@users.osdn.me>
+ * Copyright (C) 2009-2013, 2020, MinGW.org Project
  *
  *
  * Implementation of GUI specific API extensions, providing support
@@ -395,6 +395,7 @@ int dmhTypeGUI::notify( const dmh_severity code, const char *fmt, va_list argv )
        * to the buffered collection.
        */
       msglen += vsprintf( (msgbuf = newbuf) + msglen, fmt, argv );
+      return newlen - 1;
     }
   }
   else if( (msgbuf = (char *)(malloc( newlen ))) != NULL )
@@ -406,6 +407,10 @@ int dmhTypeGUI::notify( const dmh_severity code, const char *fmt, va_list argv )
     mode = code | (mode & ~DMH_SEVERITY_MASK);
     return dispatch_message( vsprintf( msgbuf, fmt, argv ) );
   }
+  /* If we get to here, then no message was dispatched; the
+   * effective message length should be returned as zero.
+   */
+  return 0;
 }
 
 static inline HWND last_active_popup( HWND owner )
index f2c1fe3..b480e3c 100644 (file)
@@ -3,8 +3,8 @@
  *
  * $Id$
  *
- * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
- * Copyright (C) 2012, 2013, MinGW.org Project
+ * Written by Keith Marshall <keith@users.osdn.me>
+ * Copyright (C) 2012, 2013, 2020, MinGW.org Project
  *
  *
  * Implementation of the WinMain() function, providing the program
@@ -95,7 +95,6 @@ int APIENTRY WinMain
      * and identified by the diagnostic message handler...
      */
     MessageBox( NULL, e.what(), "WinMain", MB_ICONERROR );
-    return EXIT_FAILURE;
   }
   catch( runtime_error &e )
   {
@@ -104,15 +103,14 @@ int APIENTRY WinMain
      * processing of its message loop...
      */
     MessageBox( NULL, e.what(), "WinMain", MB_ICONERROR );
-    return EXIT_FAILURE;
   }
   catch(...)
   { /* ...and here, we diagnose any other error which we weren't
      * able to explicitly identify.
      */
     MessageBox( NULL, "Unknown exception", "WinMain", MB_ICONERROR );
-    return EXIT_FAILURE;
   }
+  return EXIT_FAILURE;
 }
 
 /* $RCSfile$: end of file */