Coccinelle script to fix malloc failure logging

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I am trying to work on a Coccinelle script to fix the logging
for memory allocation failures, but my knowledge of Coccinelle is limited
and only able to come up with the below, which doesn't produce any output.

The script itself is basic and doesn't cover all cases (elseif, os_alloc etc),
it just checks for MSG_ERROR in the if and if not found then add the print.


test.cocci:

@has_print@
expression E, E1, P1;
statement S;
@@

E = os_zalloc(E1);
if (E == NULL) S
<+...
wpa_printf(MSG_ERROR, P1);
...+>

@no_print depends on !has_print@
expression E, E1;
statement S;
@@

E = os_zalloc(E1);
if (E == NULL)
+{
+ wpa_printf(MSG_ERROR, "Failed to allocate memory of size %lu\n",
(unsigned long) E1);
S
+}

Running:

spatch --sp-file test.cocci  wpa_supplicant/wpa_supplicant.c --debug
--debug-cpp -o wpa_supplicant/wpa_supplicant.c

I was expecting this to fix at least a few instances. Any suggestions?

_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux