From 88e9113b7ed9745d71c3d91f17c00b878960cde9 Mon Sep 17 00:00:00 2001 From: Michael Tatarinov Date: Mon, 21 Oct 2013 11:52:19 +0400 Subject: In gpsdctl: handle the unknown action. --- gpsdctl.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'gpsdctl.c') diff --git a/gpsdctl.c b/gpsdctl.c index a1ac0844..4a9e4017 100644 --- a/gpsdctl.c +++ b/gpsdctl.c @@ -31,6 +31,7 @@ static int gpsd_control(char *action, char *argument) { int connect = -1; char buf[512]; + int status; (void)syslog(LOG_ERR, "gpsd_control(action=%s, arg=%s)", action, argument); if (access(control_socket, F_OK) == 0 && @@ -73,17 +74,20 @@ static int gpsd_control(char *action, char *argument) if (stat(argument, &sb) != 1) (void)chmod(argument, sb.st_mode | S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP); (void)snprintf(buf, sizeof(buf), "+%s\r\n", argument); - ignore_return(write(connect, buf, strlen(buf))); + status = write(connect, buf, strlen(buf)); ignore_return(read(connect, buf, 12)); } else if (strcmp(action, "remove") == 0) { (void)snprintf(buf, sizeof(buf), "-%s\r\n", argument); - ignore_return(write(connect, buf, strlen(buf))); + status = write(connect, buf, strlen(buf)); ignore_return(read(connect, buf, 12)); + } else { + (void)syslog(LOG_ERR, "unknown action \"%s\"", action); + status = -1; } /*@ +sefparams @*/ (void)close(connect); //syslog(LOG_DEBUG, "gpsd_control ends"); - return 0; + return status; } int main(int argc, char *argv[]) -- cgit v1.2.1