[m-rev.] diff: avoid warnings from gcc 4.3

Julien Fischer juliensf at csse.unimelb.edu.au
Mon Jun 1 17:10:58 AEST 2009


Avoid warnings from gcc 4.3 in the runtime.

runtime/mercury_stack_trace.c:
 	Handle values of type MR_Level in format strings correctly.

runtime/mercury_wrapper.c:
 	Check the return value of a call to system().

Julien.

Index: mercury_stack_trace.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_stack_trace.c,v
retrieving revision 1.83
diff -u -r1.83 mercury_stack_trace.c
--- mercury_stack_trace.c	28 Nov 2008 05:55:14 -0000	1.83
+++ mercury_stack_trace.c	1 Jun 2009 07:01:12 -0000
@@ -1164,9 +1164,11 @@
      if (! include_trace_data) {
          if (num_levels > 1) {
              if (num_levels != dump_info.MR_sdi_num_frames) {
-                fprintf(fp, " %3dx ", num_levels);
+                fprintf(fp, " %3" MR_INTEGER_LENGTH_MODIFIER "ux ",
+                    num_levels);
              } else {
-                fprintf(fp, " %3d* ", num_levels);
+                fprintf(fp, " %3" MR_INTEGER_LENGTH_MODIFIER "u* ",
+                    num_levels);
              }
          } else {
              fprintf(fp, "%5s ", "");
Index: mercury_wrapper.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_wrapper.c,v
retrieving revision 1.194
diff -u -r1.194 mercury_wrapper.c
--- mercury_wrapper.c	3 Nov 2008 11:56:18 -0000	1.194
+++ mercury_wrapper.c	1 Jun 2009 07:07:20 -0000
@@ -2910,7 +2910,11 @@

              snprintf(cmd_buf, MAX_MEM_USAGE_REPORT_CMD_SIZE,
                  "cp /proc/%d/status %s", getpid(), filename_buf);
-            system(cmd_buf);
+            if (system(cmd_buf) != 0) {
+                fprintf(stderr, "%s: cannot write memory usage report\n",
+                    MR_progname);
+                /* There is no point in aborting. */
+            };
              break;
          }


--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list