Use a named variable to make the boolean condition explicit. Pure
refactoring, except applying De Morgan's law to avoid the confusing
double negative condition.
---
options/keys.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/options/keys.c b/options/keys.c
index 52b2736..3a49273 100644
--- a/options/keys.c
+++ b/options/keys.c
@@ -20,6 +20,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <stdbool.h>
#include <unistd.h>
#include <termios.h>
#include <string.h>
@@ -152,9 +153,12 @@ get_keys (struct key_store *ks, const char *device, const char
*uuid,
if (ks) {
for (i = 0; i < ks->nr_keys; ++i) {
struct key_store_key *key = &ks->keys[i];
+ bool key_id_matches_this_device;
- if (STRNEQ (key->id, device) && (!uuid || STRNEQ (key->id, uuid)))
- continue;
+ key_id_matches_this_device =
+ STREQ (key->id, device) ||
+ (uuid && STREQ (key->id, uuid));
+ if (!key_id_matches_this_device) continue;
switch (key->type) {
case key_string:
--
2.43.0