Ticket #404 (new defect)

Opened 8 years ago

illegal initialization in src/reporting/ewhttpd/ewhttpd.c

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

Description

ewhttpd.c illegally initializes a void *:

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 ewhttpd.o ewhttpd.c

ewhttpd.c(628): warning #144: a value of type "void *" cannot be used to initialize an entity of type "void *"
     void *processed = "yes";
                       ^

C89, 6.5.7 Initialization, requires the entity to be initialized to be an object type or incomplete array; 6.1.2.5 Types, void is an incomplete type, not an object type.

This fix is legal C (though still unusual):

--- src/reporting/ewhttpd/ewhttpd.c
+++ src/reporting/ewhttpd/ewhttpd.c     
@@ -627,4 +627,2 @@
 {
-   void *processed = "yes";
-
    if( event == MG_NEW_REQUEST )
@@ -648,8 +646,8 @@
          // try to serve the request.
-         processed = NULL;
+         return NULL;
       }
    } else {
-      processed = NULL;
+      return NULL;
    }
-   return processed;
+   return "yes";
 }
Note: See TracTickets for help on using tickets.