27b360f1b5
This script is based on the idea of the nullfree script in the Linux kernel. It finds cases where a check for null pointer is done, but is unnecessary because the function already handles NULL pointer. Basic example: if (x->buf) rte_free(x->buf); can be reduced to: rte_free(x->buf); Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
34 lines
622 B
Plaintext
34 lines
622 B
Plaintext
//
|
|
// Remove unnecessary NULL pointer checks before free functions
|
|
// All these functions work like libc free which allows
|
|
// free(NULL) as a no-op.
|
|
//
|
|
@@
|
|
expression E;
|
|
@@
|
|
(
|
|
- if (E != NULL) free(E);
|
|
+ free(E);
|
|
|
|
|
- if (E != NULL) rte_bitmap_free(E);
|
|
+ rte_bitmap_free(E);
|
|
|
|
|
- if (E != NULL) rte_free(E);
|
|
+ rte_free(E);
|
|
|
|
|
- if (E != NULL) rte_hash_free(E);
|
|
+ rte_hash_free(E);
|
|
|
|
|
- if (E != NULL) rte_ring_free(E);
|
|
+ rte_ring_free(E);
|
|
|
|
|
- if (E != NULL) rte_pktmbuf_free(E);
|
|
+ rte_pktmbuf_free(E);
|
|
|
|
|
- if (E != NULL) rte_mempool_free(E);
|
|
+ rte_mempool_free(E);
|
|
|
|
|
- if (E != NULL) rte_kvargs_free(E);
|
|
+ rte_kvargs_free(E);
|
|
)
|