]> 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)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 8 Feb 2025 06:51:06 +0000 (15:51 +0900)
(cherry picked from commit 4ba3530d67d88c708c36840fbaed9935ae81faa9)

src/home/homectl.c

index b3aacbcbcf9e356c0566f52fbb35d2541c811172..2163469a50958bb266bf3c4a86366fbc85fcc5ea 100644 (file)
@@ -2553,7 +2553,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)) {
@@ -2591,7 +2591,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);
@@ -2630,7 +2630,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);