From: Orestis Floros Date: Thu, 26 Apr 2018 20:47:45 +0000 (+0300) Subject: cmd_shmlog: use parse_long() X-Git-Tag: 4.16~89^2 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=refs%2Fpull%2F3267%2Fhead;p=i3%2Fi3 cmd_shmlog: use parse_long() --- diff --git a/src/commands.c b/src/commands.c index 6083c651..98e10c1d 100644 --- a/src/commands.c +++ b/src/commands.c @@ -2164,21 +2164,22 @@ void cmd_shmlog(I3_CMD, const char *argument) { else if (!strcmp(argument, "off")) shmlog_size = 0; else { + long new_size = 0; + if (!parse_long(argument, &new_size, 0)) { + yerror("Failed to parse %s into a shmlog size.\n", argument); + return; + } /* If shm logging now, restart logging with the new size. */ if (shmlog_size > 0) { shmlog_size = 0; LOG("Restarting shm logging...\n"); init_logging(); } - shmlog_size = atoi(argument); - /* Make a weakly attempt at ensuring the argument is valid. */ - if (shmlog_size <= 0) - shmlog_size = default_shmlog_size; + shmlog_size = (int)new_size; } LOG("%s shm logging\n", shmlog_size > 0 ? "Enabling" : "Disabling"); init_logging(); update_shmlog_atom(); - // XXX: default reply for now, make this a better reply ysuccess(true); }