Menu

#958 Invalid C in stdsoap2.c

v1.0 (example)
closed-fixed
None
5
2014-08-24
2013-12-20
No

The stanza below will not compile in visual studio. as the line "register size_t l = 0, n = 0;" is not at the start of a block. This is part of the C Standard, that gcc lets you get away with it is another matter.

#ifndef WITH_LEAN
#ifndef PALM_1
SOAP_FMAC1
char*
SOAP_FMAC2
soap_get_http_body(struct soap *soap, size_t *len)
{ if (len)
    *len = 0;
#ifndef WITH_LEAN
  register size_t l = 0, n = 0;
  register char *s;
  /* get HTTP body length */
  if (!(soap->mode & SOAP_ENC_ZLIB) && (soap->mode & SOAP_IO) != SOAP_IO_CHUNK)
  { n = soap->length;
    if (!n)
      return NULL;
  }
  DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Parsing HTTP body (mode=0x%x,len=%lu)\n", soap->mode,     (unsigned long)n));
#ifdef WITH_FAST
  soap->labidx = 0;         /* use look-aside buffer */

Discussion

  • Matthew Carey

    Matthew Carey - 2014-01-02

    Any thoughts?
    Should I just fix it so it compiles (ie insert suitable brace blocks) and submit it as a patch?

     
  • Matthew Carey

    Matthew Carey - 2014-01-02

    To fix insert a line at line 15417 containing an opening brace.
    insert line containing a matching closing brace on line 15470 of stdsoap2.c

     
  • Robert van Engelen

    Thanks for the feedback. Yes, you can modify this part of the code to compile by moving the two statements further down three lines until we release the next version in a few days/weeks.

     
  • Robert van Engelen

    • status: open --> open-accepted
    • assigned_to: Robert van Engelen
     
  • Robert van Engelen

    The SVN repository has an updated stdsoap2.c/.cpp file.

    Here is a patch that rearranges the code to avoid the compiler error:

    soap_get_http_body(struct soap *soap, size_t *len)
    {
    #ifndef WITH_LEAN
      register size_t l = 0, n = 0;
      register char *s;
      if (len)
        *len = 0;
      /* get HTTP body length */
    

    ...

    #else
      if (len)
        *len = 0;
      return NULL;
    #endif
    }
    
     
  • Robert van Engelen

    • status: open-accepted --> pending-fixed
     
  • Robert van Engelen

    • status: pending-fixed --> closed-fixed
     

Log in to post a comment.