[Devel] Compiler Warning

Norman Brandinger norm at goes.com
Wed Nov 16 15:35:33 CET 2005


A recent patch posted by Anad (nicer compiling) produces a compile 
without alot of messages.  Compiler warning are still produced.  I noted 
that there was a warning in items.c line 925.  Below are some possible 
issues that I've uncovered in regard to this.

1. In parser/parse_content.h the comments state that the value returned 
is an integer, however, it's cast as a long.  Either the comment or the 
code should be reviewed.
2. Both get_content_type() and get_content_length() are set to the same 
value.  This probably isn't what was intended.
3. In parser/msg_parser.c below, the DBG statement wants to display the 
content length, however, the value that is being used is hdr->parsed, 
not hdr->body.len.

It appears "on the surface" that there may be some problems here, it's 
also possible that code was intentionally written this way.  Can one of 
the developers confirm if there is a problem.

Regards,
Norm



parser/parse_content.h

/*
 * returns the content-length value of a sip_msg as an integer
 */
#define get_content_length(_msg_)   
((long)((_msg_)->content_length->parsed))


/*
 * returns the content-type value of a sip_msg as an integer
 */
#define get_content_type(_msg_)   
((int)(long)((_msg_)->content_type->parsed))




parser/msg_parser.c

                case HDR_CONTENTLENGTH_T:
                        hdr->body.s=tmp;
                        tmp=parse_content_length(tmp,end, &integer);
                        if (tmp==0){
                                LOG(L_ERR, "ERROR:get_hdr_field: bad 
content_length header\n");
                                goto error;
                        }
                        hdr->parsed=(void*)(long)integer;
                        hdr->body.len=tmp-hdr->body.s;
                        DBG("DEBUG: get_hdr_body : content_length=%d\n",
                                        (int)(long)hdr->parsed);
                        break;




More information about the Devel mailing list