commit 331565ea2228a0c20fbe2947adbf76b9856711be
parent 326b1d515808f8b97fa7a8693bdd405ef0faa911
Author: parazyd <parazyd@dyne.org>
Date: Tue, 30 Mar 2021 00:09:42 +0200
Cancel ugliness.
Diffstat:
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/cancel.c b/cancel.c
@@ -30,15 +30,15 @@ static const char *karens[] = {
static void lynch(int unused, GtkWidget *entry)
{
- char req[128];
+ int fd;
+ char req[64];
struct hostent *he;
struct sockaddr_in addr;
- int sockfd;
if ((he = gethostbyname("bitreich.org")) == NULL)
return;
- if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1)
+ if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
return;
addr.sin_family = AF_INET;
@@ -49,15 +49,13 @@ static void lynch(int unused, GtkWidget *entry)
snprintf(req, sizeof(req), "/cancel\t%s\r\n",
gtk_entry_get_text(GTK_ENTRY(entry)));
- if (connect(sockfd, (struct sockaddr *)&addr, sizeof(struct sockaddr)) == -1)
+ if (connect(fd, (struct sockaddr *)&addr, sizeof(struct sockaddr)) < 0)
goto out;
- if (send(sockfd, req, strlen(req), 0) == -1)
- goto out;
+ send(fd, req, strlen(req), 0);
out:
- close(sockfd);
-
+ close(fd);
(void)unused;
}