diff --git a/drivers/dstate.c b/drivers/dstate.c index 46a3bfb80e..2b36688291 100644 --- a/drivers/dstate.c +++ b/drivers/dstate.c @@ -847,26 +847,15 @@ static int sock_arg(conn_t *conn, size_t numarg, char **arg) if (upsh.instcmd) { ret = upsh.instcmd(cmdname, cmdparam); - if (ret != STAT_INSTCMD_UNKNOWN) { - /* send back execution result if requested */ - if (cmdid) - send_tracking(conn, cmdid, ret); - - /* The command was handled, status is a separate consideration */ - return 1; - } /* else try other handler(s) */ - } /* else try other handler(s) */ + /* send back execution result if requested */ + if (cmdid) + send_tracking(conn, cmdid, ret); - /* Finally try the fallback handler shared by all drivers */ - ret = main_instcmd_fallback(cmdname, cmdparam, conn); - /* send back execution result if requested */ - if (cmdid) - send_tracking(conn, cmdid, ret); + /* The command was handled, status is a separate consideration */ + return 1; + } - if (ret == STAT_INSTCMD_UNKNOWN) - upslogx(LOG_NOTICE, - "Got INSTCMD '%s', but driver lacks a handler", - NUT_STRARG(cmdname)); + upslogx(LOG_NOTICE, "Got INSTCMD, but driver lacks a handler"); return 1; } diff --git a/drivers/main.c b/drivers/main.c index 0d854d810f..bc2eda3691 100644 --- a/drivers/main.c +++ b/drivers/main.c @@ -947,9 +947,8 @@ int upsdrv_shutdown_sdcommands_or_default(const char *sdcmds_default, char **cmd return sdret; } -/* handle instant commands common for all drivers - fallback for common - * command names that could be implemented in a driver but were not */ -int main_instcmd_fallback(const char *cmdname, const char *extra, conn_t *conn) { +/* handle instant commands common for all drivers */ +int main_instcmd(const char *cmdname, const char *extra, conn_t *conn) { char buf[SMALLBUF]; if (conn) #ifndef WIN32 @@ -981,29 +980,6 @@ int main_instcmd_fallback(const char *cmdname, const char *extra, conn_t *conn) return STAT_INSTCMD_HANDLED; } - /* By default, the driver-specific values are - * unknown to shared standard handler */ - upsdebugx(2, "shared %s() does not handle command %s, " - "proceeding to driver-specific handler", - __func__, cmdname); - return STAT_INSTCMD_UNKNOWN; -} - -/* handle instant commands common for all drivers */ -int main_instcmd(const char *cmdname, const char *extra, conn_t *conn) { - char buf[SMALLBUF]; - if (conn) -#ifndef WIN32 - snprintf(buf, sizeof(buf), "socket %d", conn->fd); -#else - snprintf(buf, sizeof(buf), "handle %p", conn->fd); -#endif - else - snprintf(buf, sizeof(buf), "(null)"); - - upsdebugx(2, "entering main_instcmd(%s, %s) for [%s] on %s", - cmdname, extra, NUT_STRARG(upsname), buf); - if (!strcmp(cmdname, "driver.killpower")) { /* An implementation of `drivername -k` requested from * the running and connected driver instance by protocol diff --git a/drivers/main.h b/drivers/main.h index 249a2b1202..864eb11b7a 100644 --- a/drivers/main.h +++ b/drivers/main.h @@ -63,10 +63,6 @@ int upsdrv_shutdown_sdcommands_or_default(const char *sdcmds_default, char **cmd */ int main_instcmd(const char *cmdname, const char *extra, conn_t *conn); -/* handle instant commands common for all drivers - fallback for common - * command names that could be implemented in a driver but were not */ -int main_instcmd_fallback(const char *cmdname, const char *extra, conn_t *conn); - /* handle setting variables common for all drivers * (returns STAT_SET_* state values per enum in upshandler.h) */ diff --git a/drivers/skel.c b/drivers/skel.c index 595e4dc0d1..3cb620ab1c 100644 --- a/drivers/skel.c +++ b/drivers/skel.c @@ -127,11 +127,6 @@ void upsdrv_shutdown(void) /* static int instcmd(const char *cmdname, const char *extra) { - if (!strcasecmp(cmdname, "shutdown.default")) { - // optional custom implementation - but we - // prefer to code upsdrv_shutdown() directly - } - if (!strcasecmp(cmdname, "test.battery.stop")) { ser_send_buf(upsfd, ...); return STAT_INSTCMD_HANDLED;