tree-wide: mark set-but-not-used variables as unused to make LLVM happy

LLVM 13 introduced `-Wunused-but-set-variable` diagnostic flag, which
trips over some intentionally set-but-not-used variables or variables
attached to cleanup handlers with side effects (`_cleanup_umask_`,
`_cleanup_(notify_on_cleanup)`, `_cleanup_(restore_sigsetp)`, etc.):

```
../src/basic/process-util.c:1257:46: error: variable 'saved_ssp' set but not used [-Werror,-Wunused-but-set-variable]
        _cleanup_(restore_sigsetp) sigset_t *saved_ssp = NULL;
                                                     ^
                                                     1 error generated.
```
This commit is contained in:
Frantisek Sumsal
2021-09-15 13:09:45 +02:00
parent bd8ea741a4
commit d7ac09520b
33 changed files with 51 additions and 43 deletions
+6 -3
View File
@@ -94,7 +94,8 @@ int device_add_property_aux(sd_device *device, const char *key, const char *valu
properties = &device->properties;
if (value) {
_cleanup_free_ char *new_key = NULL, *new_value = NULL, *old_key = NULL, *old_value = NULL;
_unused_ _cleanup_free_ char *old_value = NULL;
_cleanup_free_ char *new_key = NULL, *new_value = NULL, *old_key = NULL;
int r;
r = ordered_hashmap_ensure_allocated(properties, &string_hash_ops_free_free);
@@ -119,7 +120,8 @@ int device_add_property_aux(sd_device *device, const char *key, const char *valu
TAKE_PTR(new_key);
TAKE_PTR(new_value);
} else {
_cleanup_free_ char *old_key = NULL, *old_value = NULL;
_unused_ _cleanup_free_ char *old_value = NULL;
_cleanup_free_ char *old_key = NULL;
old_value = ordered_hashmap_remove2(*properties, key, (void**) &old_key);
}
@@ -1939,7 +1941,8 @@ _public_ int sd_device_get_trigger_uuid(sd_device *device, sd_id128_t *ret) {
}
static int device_cache_sysattr_value(sd_device *device, const char *key, char *value) {
_cleanup_free_ char *new_key = NULL, *old_value = NULL;
_unused_ _cleanup_free_ char *old_value = NULL;
_cleanup_free_ char *new_key = NULL;
int r;
assert(device);
+1 -1
View File
@@ -53,7 +53,7 @@ static void test_catalog_import_invalid(void) {
}
static void test_catalog_import_badid(void) {
_cleanup_ordered_hashmap_free_free_free_ OrderedHashmap *h = NULL;
_unused_ _cleanup_ordered_hashmap_free_free_free_ OrderedHashmap *h = NULL;
const char *input =
"-- 0027229ca0644181a76c4e92458afaff dededededededededededededededede\n" \
"Subject: message\n" \