Skip to content

Commit 6b90acb

Browse files
committed
Fix sign compare warning
Store the result of asprintf() in an int, not size_t.
1 parent 46274e7 commit 6b90acb

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/sudo.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -620,12 +620,13 @@ get_user_info(struct user_details *ud)
620620

621621
ttydev = get_process_ttyname(path, sizeof(path));
622622
if (ttydev != (dev_t)-1) {
623+
int len;
623624
#if SIZEOF_DEV_T == SIZEOF_LONG
624-
n = asprintf(&info[++i], "ttydev=%lu", (unsigned long)ttydev);
625+
len = asprintf(&info[++i], "ttydev=%lu", (unsigned long)ttydev);
625626
#else
626-
n = asprintf(&info[++i], "ttydev=%llu", (unsigned long long)ttydev);
627+
len = asprintf(&info[++i], "ttydev=%llu", (unsigned long long)ttydev);
627628
#endif
628-
if (n == -1)
629+
if (len == -1)
629630
goto oom;
630631
info[++i] = sudo_new_key_val("tty", path);
631632
if (info[i] == NULL)

0 commit comments

Comments
 (0)