Menu

#20 C non trivial warnings

v1.0 (example)
closed-accepted
None
5
2015-01-05
2014-12-25
No

C warnings

  • smartcard/scard/scard_wrap.c:4039:17: warning: attempt to free a non-heap object ‘temp3’ [-Wfree-nonheap-object]
  • smartcard/scard/scard_wrap.c:4054:17: warning: attempt to free a non-heap object ‘temp3’ [-Wfree-nonheap-object]
  • smartcard/scard/scard_wrap.c:5056:17: warning: attempt to free a non-heap object ‘temp4’ [-Wfree-nonheap-object]
  • smartcard/scard/scard_wrap.c:5084:17: warning: attempt to free a non-heap object ‘temp4’ [-Wfree-nonheap-object]
  • smartcard/scard/scard_wrap.c:4944:17: warning: attempt to free a non-heap object ‘temp5’ [-Wfree-nonheap-object]
  • smartcard/scard/scard_wrap.c:4980:17: warning: attempt to free a non-heap object ‘temp5’ [-Wfree-nonheap-object]
  • smartcard/scard/scard_wrap.c:4741:17: warning: attempt to free a non-heap object ‘temp2’ [-Wfree-nonheap-object]
  • smartcard/scard/scard_wrap.c:4770:17: warning: attempt to free a non-heap object ‘temp2’ [-Wfree-nonheap-object]
  • smartcard/scard/scard_wrap.c:4625:17: warning: attempt to free a non-heap object ‘temp3’ [-Wfree-nonheap-object]
  • smartcard/scard/scard_wrap.c:4681:17: warning: attempt to free a non-heap object ‘temp3’ [-Wfree-nonheap-object]
  • smartcard/scard/scard_wrap.c:4194:17: warning: attempt to free a non-heap object ‘temp4’ [-Wfree-nonheap-object]
  • smartcard/scard/scard_wrap.c:4222:17: warning: attempt to free a non-heap object ‘temp4’ [-Wfree-nonheap-object]

Discussion

  • Ludovic Rousseau

    I also get these warnings:

     In file included from smartcard/scard/scard_wrap.c:2991:0:
     smartcard/scard/scard_wrap.c: In function ‘_wrap_SCardGetAttrib’:
     smartcard/scard/memlog.h:50:26: warning: attempt to free a non-heap object ‘temp3’ [-Wfree-nonheap-object]
         #define mem_Free free
                          ^
     smartcard/scard/scard_wrap.c:4025:9: note: in expansion of macro ‘mem_Free’
         mem_Free( arg3 );
         ^
    

    This code is generated by SWIG http://www.swig.org/. So I can do much.

    It looks like false positives from the C compiler. The memory is allocated in another function and that confuses the C compiler.

    I trust SWIG to do the right thing:

    if(NULL!=arg3)
    {
      if(NULL!=arg3->ab)
      {
        mem_Free( arg3->ab );
      }
      if(arg3->bAllocated==TRUE)
      {
        mem_Free( arg3 );
      }
    }
    

    I don't know how to fix these warnings. Maybe you should report the problem to SWIG?

     
  • Alon Bar-Lev

    Alon Bar-Lev - 2014-12-30

    yes, I agree, this is false positive, I reviewed the code.

    I did not know this is generated code.

     
  • Ludovic Rousseau

    • status: open --> closed-accepted
    • assigned_to: Ludovic Rousseau
     

Log in to post a comment.