Commit graph

21 commits

Author SHA1 Message Date
Ondřej Surý
f0989bdf03 The dns_message_create() cannot fail, change the return to void
The dns_message_create() function cannot soft fail (as all memory
allocations either succeed or cause abort), so we change the function to
return void and cleanup the calls.

(cherry picked from commit 33eefe9f85)
2020-09-30 14:26:26 +02:00
Diego Fronza
46f22df54c cocci: Add semantic patch to refactor dns_message_destroy()
dns_message_t objects are now being handled using reference counting
semantics, so now dns_message_destroy() is not called directly anymore,
dns_message_detach must be called instead.

(cherry picked from commit 7deaf9a93c)
2020-09-30 11:35:23 +10:00
Ondřej Surý
bc1d4c9cb4 Clear the pointer to destroyed object early using the semantic patch
Also disable the semantic patch as the code needs tweaks here and there because
some destroy functions might not destroy the object and return early if the
object is still in use.
2020-02-09 18:00:17 -08:00
Ondřej Surý
b97d003033 Add semantic patch to NULL the destroyed pointer early
Our destroy functions usually look like this:

    void
    foo_destroy(foo_t **foop) {
        foo_t foo = *foop;
        ...destroy the contents of foo...
        *foop = NULL;
    }

nulling the pointer should be done as soon as possible which is
not always the case.  This commit adds simple semantic patch that
changes the example function to:

    void
    foo_destroy(foo_t **foop) {
        foo_t foo = *foop;
        *foop = NULL;
        ...destroy the contents of foo...
    }
2020-02-09 18:00:16 -08:00
Ondřej Surý
d5f682a00b Add semantic patch to fix isc_buffer_allocate usage, it cannot fail now 2020-02-03 08:29:00 +01:00
Ondřej Surý
33328871a7 Add semantic patch to refactor isc_mempool_create() usage 2020-02-03 08:27:12 +01:00
Ondřej Surý
9dfa33050b Add semantic patch to find void f() { ... return ((void)g())); ... }
When a function returns void, it can be used as an argument to return in
function returning also void, e.g.:

void in(void) {
  return;
}

void out(void) {
  return (in());
}

while this is legal, it should be rewritten as:

void out(void) {
  in();
  return;
}

The semantic patch just find the occurrences, and they need to be fixed
by hand.
2019-12-06 13:42:18 +01:00
Ondřej Surý
7a69ac32c9 Disable no longer useful semantic patches
Some semantic patches are meant to be run just once, as they work on
functions with changed prototypes. We keep them for reference, but
disabled them from the CI to save time.
2019-11-29 14:26:14 +01:00
Ondřej Surý
21902d0ac7 cocci: Add semantic patch to refactor dns_name_dup() usage 2019-11-29 13:59:40 +01:00
Ondřej Surý
ac26ecf540 Add semantic patch to replace RUNTIME_CHECK(dns_name_copy(..., NULL)) with dns_name_copynf 2019-10-01 10:43:26 +10:00
Ondřej Surý
406eba0c41 Add semantic patches to correctly check dns_name_copy(..., NULL) return code
The dns_name_copy() function cannot fail gracefully when the last argument
(target) is NULL.  Add RUNTIME_CHECK()s around such calls.

The first semantic patch adds RUNTIME_CHECK() around any call that ignores the
return value and is very safe to apply.

The second semantic patch attempts to properly add RUNTIME_CHECK() to places
where the return value from `dns_name_copy()` is recorded into `result`
variable.  The result of this semantic patch needs to be reviewed by hand.

Both patches misses couple places where the code surrounding the
`dns_name_copy(..., NULL)` usage is more complicated and is better suited to be
fixed by a human being that understands the surrounding code.
2019-10-01 10:43:26 +10:00
Ondřej Surý
6bd2eb06cb Add a semantic patch to make refactor the isc_mem_create() 2019-09-12 09:26:09 +02:00
Ondřej Surý
2d12def6ee isc_event_allocate() can't fail now, add spatch to remove the checks 2019-08-30 01:04:28 -04:00
Evan Hunt
a8595262f7 add a semantic patch for the API change 2019-08-29 10:07:41 -07:00
Ondřej Surý
d502569902 Add spatch to replace isc_mem_put+isc_mem_detach with isc_mem_putanddetach 2019-07-31 10:26:40 +02:00
Ondřej Surý
3c1d4298af Add spatch for isc_mem_allocate; it also cannot fail gracefully 2019-07-23 15:32:35 -04:00
Ondřej Surý
49f244406c Add spatch for isc_mem_strdup; it also cannot fail gracefully 2019-07-23 15:32:35 -04:00
Ondřej Surý
f63e696967 Add semantic patch to remove checking for isc_mem_get() return value
The isc_mem_get() cannot fail gracefully now, it either gets memory of
assert()s.  The added semantic patch cleans all the blocks checking whether
the return value of isc_mem_get() was NULL.
2019-07-23 15:32:35 -04:00
Ondřej Surý
7615e86fae Add spatch to replace memcpy usage with memmove 2019-07-12 15:27:06 +02:00
Ondřej Surý
0b9f7f8a38 Add semantic patch to remove occurences of '#include <config.h>' 2019-03-08 15:15:05 +01:00
Ondřej Surý
21db43da8e Add unreachable.spatch coccinelle recipe and run it in precheck CI phase 2018-11-22 09:28:00 -05:00