]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
homectl: Fix empty checks
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 3 Feb 2025 15:17:00 +0000 (16:17 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 3 Feb 2025 18:24:31 +0000 (19:24 +0100)
src/home/homectl.c

index 724925553d84a98b48a05c25f25742bd88716e8e..b5584349e2a9be42affabad90dabe809183ca32c 100644 (file)
@@ -2555,7 +2555,7 @@ static int create_interactively(void) {
                         continue;
                 };
 
-                if (available) {
+                if (!strv_isempty(available)) {
                         r = safe_atou(s, &u);
                         if (r >= 0) {
                                 if (u <= 0 || u > strv_length(available)) {
@@ -2593,7 +2593,7 @@ static int create_interactively(void) {
                         return log_oom();
         }
 
-        if (groups) {
+        if (!strv_isempty(groups)) {
                 strv_sort_uniq(groups);
 
                 r = sd_json_variant_set_field_strv(&arg_identity_extra, "memberOf", groups);
@@ -2632,7 +2632,7 @@ static int create_interactively(void) {
                 log_notice("Specified shell '%s' is not installed, try another one.", shell);
         }
 
-        if (shell) {
+        if (!isempty(shell)) {
                 log_info("Selected %s as the shell for user %s", shell, username);
 
                 r = sd_json_variant_set_field_string(&arg_identity_extra, "shell", shell);