Menu

#1127 Unchecked return values: soap_array_reference

v1.0 (example)
closed-fixed
None
5
2017-07-24
2017-07-14
No

test.h:

struct xsd__twounderscores {
        unsigned char *__ptr;
        int __size;
};
struct xsd_oneunderscore {
        unsigned char *__ptr;
        int __size;
};

This produces a soapC.cpp which invokes soap_array_reference differently, once with and once without return value checking.

$ grep -n soap_array_ref soapC.cpp
1324:   if (a->__ptr && !soap_array_reference(soap, a, a->__ptr, a->__size, SOAP_TYPE_xsd_oneunderscore))
1474:           soap_array_reference(soap, a, a->__ptr, a->__size, SOAP_TYPE_xsd__twounderscores);

The complaint of the cov-scan tool is then:

CID 122967 (#1 of 1): Unchecked return value (CHECKED_RETURN)
2. check_return: Calling soap_array_reference without checking return value (as is done elsewhere 13 out of 15 times).

Reason: ignoring the return value of functions can mean troubles, for example with the read function. Cov thinks that, because the value is unignored most of the time that the remaining times where it is ignored is a bug in the same style.

The number 13/15 is specific to our fullsize .h file we give to soapcpp2; for this test.h, it would probably say "1 out of 2".

Discussion

  • Robert van Engelen

    The return value can be safely ignored (it is only needed in some cases for logic flow). I'll add a void cast to appease Coverity.

     
  • Robert van Engelen

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

    • private: No --> Yes
     
  • Robert van Engelen

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

    • private: Yes --> No
     

Log in to post a comment.