summaryrefslogtreecommitdiffstats
path: root/coccinelle (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* tree-wide: make use of new STRLEN() macro everywhere (#7639)Lennart Poettering2017-12-141-0/+10
| | | | | Let's employ coccinelle to do this for us. Follow-up for #7625.
* tree-wide: drop a few == NULL and != NULL comparisonLennart Poettering2017-12-111-0/+14
| | | | | | | Our CODING_STYLE suggests not comparing with NULL, but relying on C's downgrade-to-bool feature for that. Fix up some code to match these guidelines. (This is not comprehensive, the coccinelle output for this is unfortunately kinda borked)
* core: use empty_to_null() where we canLennart Poettering2017-12-071-0/+5
|
* coccinelle: improve run-coccinelle.sh to take list of scripts to runLennart Poettering2017-12-071-1/+1
| | | | | Let's tweak run-coccinelle.sh to optionally take a list of scripts to run. If not specified, run all scripts, as before.
* coccinelle: add a run-coccinelle.sh script that runs all scriptsLennart Poettering2017-11-291-0/+11
| | | | | One day we should start running something like this as part of CI so that non-well-formed commits are not even accepted...
* coccinelle: fix IN_SET/!IN_SET scripts, and apply some changes it foundLennart Poettering2017-11-292-130/+56
| | | | | | | | IN_SET only works for constant values, hence clarify that. Moreover, we declared a statement "s" we never made use of. Drop it. Also, for both scripts, let's support 10 items. More causes spatch to die with "Stack overflow" for me.
* tree-wide: use strv_isempty() instead of strv_length() == 0Lennart Poettering2017-11-291-0/+15
| | | | It's a lot faster in many cases, since it's O(1) rather than O(n).
* tree-wide: use `!IN_SET(..)` for `a != b && a != c && …`Andreas Rammhold2017-10-021-0/+147
| | | | | | The included cocci was used to generate the changes. Thanks to @flo-wer for pointing this case out.
* tree-wide: use IN_SET where possibleAndreas Rammhold2017-10-021-0/+35
| | | | | In addition to the changes from #6933 this handles cases that could be matched with the included cocci file.
* tree-wide: drop NULL sentinel from strjoinZbigniew Jędrzejewski-Szmek2016-10-231-0/+16
| | | | | | | | | | | | | 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.
* tree-wide: introduce free_and_replace helperZbigniew Jędrzejewski-Szmek2016-10-171-0/+15
| | | | | | 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.
* tree-wide: use mfree moreZbigniew Jędrzejewski-Szmek2016-10-171-0/+6
|
* tree-wide: htonl() is weird, let's use htobe32() instead (#3538)Lennart Poettering2016-06-151-0/+20
| | | Super-important change, yeah!
* tree-wide: remove useless NULLs from strjoinaZbigniew Jędrzejewski-Szmek2016-04-131-0/+6
| | | | The coccinelle patch didn't work in some places, I have no idea why.
* tree-wide: use xsprintf() where applicableDaniel Mack2016-01-121-0/+6
| | | | Also add a coccinelle receipt to help with such transitions.
* coccinelle: additional errno.cocci hunkMichal Schmidt2015-11-091-0/+7
| | | | | | | | rewrites: log_error_errno(errno, ...); return -errno; into: return log_error_errno(errno, ...);
* coccinelle: errno.cocci improvementsMichal Schmidt2015-11-091-36/+13
| | | | Apply to all log_*_errno loglevels.
* Add Coccinelle patch for strempty() usageDaniel Mack2015-09-301-0/+10
|
* util: add safe_closedir() similar to safe_fclose()Lennart Poettering2015-09-221-0/+27
|
* tree-wide: take benefit of the fact that hashmap_free() returns NULLLennart Poettering2015-09-091-0/+54
| | | | | | And set_free() too. Another Coccinelle patch.
* tree-wide: make use of the fact that strv_free() returns NULLLennart Poettering2015-09-091-0/+27
| | | | Another Coccinelle patch.
* Merge pull request #1218 from poettering/safe-fcloseDaniel Mack2015-09-091-0/+27
|\ | | | | util: introduce safe_fclose() and port everything over to it
| * util: introduce safe_fclose() and port everything over to itLennart Poettering2015-09-091-0/+27
| | | | | | | | Adds a coccinelle script to port things over automatically.
* | tree-wide: replace while(1) by for(;;) everywhereLennart Poettering2015-09-091-0/+12
| | | | | | | | Another Coccinelle script.
* | tree-wide: update empty-if coccinelle script to cover empty-while and moreLennart Poettering2015-09-091-5/+42
| | | | | | | | Let's also clean up single-line while and for blocks.
* | tree-wide: make use of log_error_errno() return value in more casesLennart Poettering2015-09-091-18/+24
|/ | | | | | | 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.
* tree-wide: drop {} from one-line if blocksLennart Poettering2015-09-091-0/+19
| | | | Patch via coccinelle.
* tree-wide: make use of log_error_errno() return valueLennart Poettering2015-09-091-0/+42
| | | | | | | | | | | | | | | | | | | | 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");
* tree-wide: don't do assignments within if checksLennart Poettering2015-09-091-0/+20
| | | | | | | | | | | Turn this: if ((r = foo()) < 0) { ... into this: r = foo(); if (r < 0) { ...
* tree-wide: drop redundant if checks before safe_close()Lennart Poettering2015-09-091-0/+7
| | | | | | | | | | | Replace this: if (fd >= 0) safe_close(fd); by this: safe_close(fd);
* tree-wide: make more code use safe_close()Lennart Poettering2015-09-091-0/+18
| | | | | | | | | | | Replace this: close(fd); fd = -1; write this: fd = safe_close(fd);
* tree-wide: use coccinelle to patch a lot of code to use mfree()Lennart Poettering2015-09-091-0/+6
This replaces this: free(p); p = NULL; by this: p = mfree(p); Change generated using coccinelle. Semantic patch is added to the sources.