mirror of
https://gitlab.freedesktop.org/libfprint/libfprint.git
synced 2025-11-15 07:38:12 +00:00
cocci: Add spatch/coccinelle patches for driver porting
This is an impartial set of transformations to help port the drivers to the new interfaces.
This commit is contained in:
38
cocci/99-insert-checking-code.cocci
Normal file
38
cocci/99-insert-checking-code.cocci
Normal file
@@ -0,0 +1,38 @@
|
||||
// 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);
|
||||
)
|
||||
Reference in New Issue
Block a user