non dead code in macro
The line with the exit label should not be considered to be dead code in the following macro definition:
#define efi_queue_work(_rts, _arg1, _arg2, _arg3, _arg4, _arg5) \
({ \
efi_rts_work.status = EFI_ABORTED; \
\
if (!efi_enabled(EFI_RUNTIME_SERVICES)) { \
pr_warn_once("EFI Runtime Services are disabled!\n"); \
goto exit; \
} \
\
init_completion(&efi_rts_work.efi_rts_comp); \
INIT_WORK(&efi_rts_work.work, efi_call_rts); \
efi_rts_work.arg1 = _arg1; \
efi_rts_work.arg2 = _arg2; \
efi_rts_work.arg3 = _arg3; \
efi_rts_work.arg4 = _arg4; \
efi_rts_work.arg5 = _arg5; \
efi_rts_work.efi_rts_id = _rts; \
\
/* \
* queue_work() returns 0 if work was already on queue, \
* _ideally_ this should never happen. \
*/ \
if (queue_work(efi_rts_wq, &efi_rts_work.work)) \
wait_for_completion(&efi_rts_work.efi_rts_comp); \
else \
pr_err("Failed to queue work to efi_rts_wq.\n"); \
\
exit: \
efi_rts_work.efi_rts_id = EFI_NONE; \
efi_rts_work.status; \
})
See tests/efi.cocci and tests/efi.c. The desired behavior is that there should be no dead code report and the semantic patch should not crash on this file.
Reported by Markus Eflring on the Coccinelle mailing list on March 8, 2020 (https://systeme.lip6.fr/pipermail/cocci/2020-March/006930.html)