Ticket #409 (new defect)

Opened 8 years ago

questionable initialization in src/seismic_processing/eqassemble/eqassemble.c

Reported by: baker Owned by: somebody
Priority: minor Milestone: All Platforms
Component: ALL modules Version: 7.8
Keywords: eqassemble Cc:

Description

eqassemble.c uses char * variables when it should just use const char[] arrays:

icc -D_BSD_SOURCE -m32 -Dlinux -D__i386 -D_LINUX -D_INTEL -D_USE_SCHED  -D_USE_PTHREADS -D_USE_TERMIOS -I/opt/earthworm/earthworm-7.6-5880/include -no-gcc -g -O0 -Wcheck -Wformat -check=stack,uninit -traceback -m32 -Dlinux -D__i386 -D_LINUX -D_INTEL -D_USE_SCHED  -D_USE_PTHREADS -D_USE_TERMIOS -I/opt/earthworm/earthworm-7.6-5880/include  -c -o eqassemble.o eqassemble.c

eqassemble.c(858): warning #144: a value of type "char *" cannot be used to initialize an entity of type "char *"
      char *prelimPrefix = "Preliminary ";
                           ^

eqassemble.c(859): warning #144: a value of type "char *" cannot be used to initialize an entity of type "char *"
      char *rapidPrefix = "Rapid";
                          ^

eqassemble.c(860): warning #144: a value of type "char *" cannot be used to initialize an entity of type "char *"
      char *finalPrefix = "Final";
                          ^

Here's the fix:

--- src/seismic_processing/eqassemble/eqassemble.c
+++ src/seismic_processing/eqassemble/eqassemble.c      
@@ -856,6 +856,6 @@
     char txtpck[120];
-    char *reportPrefix;
-    char *prelimPrefix = "Preliminary ";
-    char *rapidPrefix = "Rapid";
-    char *finalPrefix = "Final";
+    const char *reportPrefix;
+    const char prelimPrefix[] = "Preliminary";
+    const char rapidPrefix[]  = "Rapid";
+    const char finalPrefix[]  = "Final";
     char        *eqmsg;           /* working pointer into EqMsg   */
Note: See TracTickets for help on using tickets.