Zbigniew Jędrzejewski-Szmek
605405c6cc
tree-wide: drop NULL sentinel from strjoin
...
This makes strjoin and strjoina more similar and avoids the useless final
argument.
spatch -I . -I ./src -I ./src/basic -I ./src/basic -I ./src/shared -I ./src/shared -I ./src/network -I ./src/locale -I ./src/login -I ./src/journal -I ./src/journal -I ./src/timedate -I ./src/timesync -I ./src/nspawn -I ./src/resolve -I ./src/resolve -I ./src/systemd -I ./src/core -I ./src/core -I ./src/libudev -I ./src/udev -I ./src/udev/net -I ./src/udev -I ./src/libsystemd/sd-bus -I ./src/libsystemd/sd-event -I ./src/libsystemd/sd-login -I ./src/libsystemd/sd-netlink -I ./src/libsystemd/sd-network -I ./src/libsystemd/sd-hwdb -I ./src/libsystemd/sd-device -I ./src/libsystemd/sd-id128 -I ./src/libsystemd-network --sp-file coccinelle/strjoin.cocci --in-place $(git ls-files src/*.c)
git grep -e '\bstrjoin\b.*NULL' -l|xargs sed -i -r 's/strjoin\((.*), NULL\)/strjoin(\1)/'
This might have missed a few cases (spatch has a really hard time dealing
with _cleanup_ macros), but that's no big issue, they can always be fixed
later.
2016-10-23 11:43:27 -04:00
Zbigniew Jędrzejewski-Szmek
3b319885c4
tree-wide: introduce free_and_replace helper
...
It's a common pattern, so add a helper for it. A macro is necessary
because a function that takes a pointer to a pointer would be type specific,
similarly to cleanup functions. Seems better to use a macro.
2016-10-16 23:35:39 -04:00
Zbigniew Jędrzejewski-Szmek
6b430fdb7c
tree-wide: use mfree more
2016-10-16 23:35:39 -04:00
Lennart Poettering
8e38570ebe
tree-wide: htonl() is weird, let's use htobe32() instead ( #3538 )
...
Super-important change, yeah!
2016-06-15 01:26:01 +02:00
Zbigniew Jędrzejewski-Szmek
81d621034b
tree-wide: remove useless NULLs from strjoina
...
The coccinelle patch didn't work in some places, I have no idea why.
2016-04-13 08:56:44 -04:00
Daniel Mack
d054f0a4d4
tree-wide: use xsprintf() where applicable
...
Also add a coccinelle receipt to help with such transitions.
2016-01-12 15:36:32 +01:00
Michal Schmidt
b3e3bb19a0
coccinelle: additional errno.cocci hunk
...
rewrites:
log_error_errno(errno, ...);
return -errno;
into:
return log_error_errno(errno, ...);
2015-11-09 20:01:06 +01:00
Michal Schmidt
351825cc73
coccinelle: errno.cocci improvements
...
Apply to all log_*_errno loglevels.
2015-11-09 20:01:06 +01:00
Daniel Mack
de896126ea
Add Coccinelle patch for strempty() usage
2015-09-30 12:24:16 +02:00
Lennart Poettering
ed0d40229b
util: add safe_closedir() similar to safe_fclose()
2015-09-22 16:30:24 +02:00
Lennart Poettering
525d3cc746
tree-wide: take benefit of the fact that hashmap_free() returns NULL
...
And set_free() too.
Another Coccinelle patch.
2015-09-09 23:12:07 +02:00
Lennart Poettering
6796073e33
tree-wide: make use of the fact that strv_free() returns NULL
...
Another Coccinelle patch.
2015-09-09 23:05:58 +02:00
Daniel Mack
01da201420
Merge pull request #1218 from poettering/safe-fclose
...
util: introduce safe_fclose() and port everything over to it
2015-09-09 15:45:03 +02:00
Lennart Poettering
74ca738f6a
util: introduce safe_fclose() and port everything over to it
...
Adds a coccinelle script to port things over automatically.
2015-09-09 15:26:11 +02:00
Lennart Poettering
57255510c9
tree-wide: replace while(1) by for(;;) everywhere
...
Another Coccinelle script.
2015-09-09 14:59:53 +02:00
Lennart Poettering
1f6b411372
tree-wide: update empty-if coccinelle script to cover empty-while and more
...
Let's also clean up single-line while and for blocks.
2015-09-09 14:59:51 +02:00
Lennart Poettering
94c156cd45
tree-wide: make use of log_error_errno() return value in more cases
...
The previous coccinelle semantic patch that improved usage of
log_error_errno()'s return value, only looked for log_error_errno()
invocations with a single parameter after the error parameter. Update
the patch to handle arbitrary numbers of additional arguments.
2015-09-09 14:58:26 +02:00
Lennart Poettering
ece174c543
tree-wide: drop {} from one-line if blocks
...
Patch via coccinelle.
2015-09-09 08:20:20 +02:00
Lennart Poettering
76ef789d26
tree-wide: make use of log_error_errno() return value
...
Turns this:
r = -errno;
log_error_errno(errno, "foo");
into this:
r = log_error_errno(errno, "foo");
and this:
r = log_error_errno(errno, "foo");
return r;
into this:
return log_error_errno(errno, "foo");
2015-09-09 08:20:20 +02:00
Lennart Poettering
3cc2aff1ab
tree-wide: don't do assignments within if checks
...
Turn this:
if ((r = foo()) < 0) { ...
into this:
r = foo();
if (r < 0) { ...
2015-09-09 08:20:20 +02:00
Lennart Poettering
7f6e12b033
tree-wide: drop redundant if checks before safe_close()
...
Replace this:
if (fd >= 0)
safe_close(fd);
by this:
safe_close(fd);
2015-09-09 08:20:19 +02:00
Lennart Poettering
66e405837b
tree-wide: make more code use safe_close()
...
Replace this:
close(fd);
fd = -1;
write this:
fd = safe_close(fd);
2015-09-09 08:20:19 +02:00
Lennart Poettering
a1e58e8ee1
tree-wide: use coccinelle to patch a lot of code to use mfree()
...
This replaces this:
free(p);
p = NULL;
by this:
p = mfree(p);
Change generated using coccinelle. Semantic patch is added to the
sources.
2015-09-09 08:19:27 +02:00