libfprint/cocci/99-insert-checking-code.cocci
Benjamin Berg 6ec11a2b26 cocci: Add spatch/coccinelle patches for driver porting
This is an impartial set of transformations to help port the drivers to
the new interfaces.
2019-11-20 13:53:45 +01:00

39 lines
994 B
Plaintext

// If we have matches on error conditions, the we likely have a memory
// mangement error.
@ forall @
identifier error;
statement S;
@@
if (<+... g_error_matches(error, ...) ...+>) {
+ _Pragma ("GCC error \"Inserted possibly wrong g_error_free!\"");
+ if (error)
+ g_error_free (error);
...
} else S
@ forall @
identifier error;
@@
if (<+... g_error_matches(error, ...) ...+>) {
+ _Pragma ("GCC error \"Inserted possibly wrong g_error_free!\"");
+ if (error)
+ g_error_free (error);
...
}
@@
expression transfer;
identifier r;
statement S;
@@
(
- r = libusb_cancel_transfer(transfer);
- if (r < 0) S
+ _Pragma("GCC warning \"Removed libusb_cancel_transfer call!\"");
+ g_warning("USB transfer %p should be cancelled but was not due to a lack of code migration!", transfer);
|
- libusb_cancel_transfer(transfer);
+ _Pragma("GCC warning \"Removed libusb_cancel_transfer call!\"");
+ g_warning("USB transfer %p should be cancelled but was not due to a lack of code migration!", transfer);
)