From 8260b0af7f2872051b35437b4740b75ccc189c54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?c=C3=A6l=C5=8Drum=20spect=C4=81tr=C4=ABx?= Date: Mon, 17 Nov 2025 19:43:01 +0100 Subject: [PATCH] Use uid_t to avoid signed comparison warning, output diagnostic messages to stderr --- kissy.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kissy.c b/kissy.c index 5167a5b..4c7763d 100644 --- a/kissy.c +++ b/kissy.c @@ -53,7 +53,7 @@ int main (int argc, char **argv) { printf("%s\n", "Cannot find target"); return 1; } - int target = pw->pw_uid; + uid_t target = pw->pw_uid; // get current username struct passwd *pw2 = getpwuid(getuid()); @@ -74,7 +74,7 @@ int main (int argc, char **argv) { // iterate over all files in directory DIR *dir = opendir("/dev/pts"); while (1) { - struct dirent *ent = readdir (dir); + struct dirent *ent = readdir(dir); if (ent == NULL) break; @@ -90,7 +90,7 @@ int main (int argc, char **argv) { kissed = true; if (stats.st_gid != getegid()) { // are we running as the tty user? - printf("%s\n", "Mismatch between file owner group and current effective group. Make sure this program is running with setgid."); + fprintf(stderr, "%s\n", "Mismatch between file owner group and current effective group. Make sure this program is running with setgid."); } else { FILE *tty = fopen(filepath, "a"); // write to terminal! fprintf(tty, "\n%s\n--%s\n", kiss, user); @@ -101,5 +101,5 @@ int main (int argc, char **argv) { // print a message if a suitable terminal couldn't be found if (!kissed) - printf("%s\n", "Couldn't find any suitable terminals. User is not logged in or has not enabled messages."); -} \ No newline at end of file + fprintf(stderr, "%s\n", "Couldn't find any suitable terminals. User is not logged in or has not enabled messages."); +}