Use dns_fixedname_initname() where possible

Replace dns_fixedname_init() calls followed by dns_fixedname_name()
calls with calls to dns_fixedname_initname() where it is possible
without affecting current behavior and/or performance.

This patch was mostly prepared using Coccinelle and the following
semantic patch:

    @@
    expression fixedname, name;
    @@
    -	dns_fixedname_init(&fixedname);
    	...
    -	name = dns_fixedname_name(&fixedname);
    +	name = dns_fixedname_initname(&fixedname);

The resulting set of changes was then manually reviewed to exclude false
positives and apply minor tweaks.

It is likely that more occurrences of this pattern can be refactored in
an identical way.  This commit only takes care of the low-hanging fruit.

(cherry picked from commit 4df4a8e731)
(cherry picked from commit 0041aeb751)
This commit is contained in:
Michał Kępień
2018-03-28 14:38:09 +02:00
committed by Evan Hunt
parent 1dea0795d1
commit ecea678dac
84 changed files with 317 additions and 634 deletions

View File

@@ -874,8 +874,7 @@ name. This allows names to be stack-allocated with minimal initialization:
dns_fixedname_t fn;
dns_name_t *name;
dns_fixedname_init(&fn)
name = dns_fixedname_name(&fn);
name = dns_fixedname_initname(&fn);
`name` is now a pointer to a `dns_name` object in which a name can be
stored for the duration of this function; there is no need to initialize,