diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2022-09-10 15:44:41 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2022-09-10 15:44:41 +0200 |
commit | a9ee361f27e0439530387765924574e5358c8a5c (patch) | |
tree | 3104aecc4d574f7d7bbb269223814586277b1797 /src/ipmievd.c | |
parent | 82ac6c87ce0b0af2fb8de25d70442fec406bb742 (diff) |
New upstream version 1.8.19upstream/1.8.19upstream
Diffstat (limited to 'src/ipmievd.c')
-rw-r--r-- | src/ipmievd.c | 79 |
1 files changed, 39 insertions, 40 deletions
diff --git a/src/ipmievd.c b/src/ipmievd.c index 67788e5..6a94b1f 100644 --- a/src/ipmievd.c +++ b/src/ipmievd.c @@ -29,8 +29,6 @@ * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. */ -#define _XOPEN_SOURCE 700 -#define _BSD_SOURCE #include <stdio.h> #include <fcntl.h> @@ -56,8 +54,8 @@ # include <paths.h> #endif -#ifndef _PATH_VARRUN -# define _PATH_VARRUN "/var/run/" +#ifndef _PATH_RUN +# define _PATH_RUN "/run/" #endif #ifdef IPMI_INTF_OPEN @@ -84,7 +82,7 @@ #include <ipmitool/ipmi_main.h> #define WARNING_THRESHOLD 80 -#define DEFAULT_PIDFILE _PATH_VARRUN "ipmievd.pid" +#define DEFAULT_PIDFILE _PATH_RUN "ipmievd.pid" char pidfile[64]; /* global variables */ @@ -125,7 +123,7 @@ static int openipmi_wait(struct ipmi_event_intf * eintf); static int openipmi_read(struct ipmi_event_intf * eintf); static struct ipmi_event_intf openipmi_event_intf = { .name = "open", - .desc = "OpenIPMI asyncronous notification of events", + .desc = "OpenIPMI asynchronous notification of events", .prefix = "", .setup = openipmi_setup, .wait = openipmi_wait, @@ -175,7 +173,7 @@ ipmievd_usage(void) * * @name: interface name to try and load * - * returns pointer to inteface structure if found + * returns pointer to interface structure if found * returns NULL on error */ static struct ipmi_event_intf * @@ -184,16 +182,17 @@ ipmi_event_intf_load(char * name) struct ipmi_event_intf ** intf; struct ipmi_event_intf * i; - if (name == NULL) { + if (!name) { i = ipmi_event_intf_table[0]; return i; } for (intf = ipmi_event_intf_table; - ((intf != NULL) && (*intf != NULL)); - intf++) { + intf && *intf; + intf++) + { i = *intf; - if (strncmp(name, i->name, strlen(name)) == 0) { + if (!strcmp(name, i->name)) { return i; } } @@ -225,7 +224,7 @@ log_event(struct ipmi_event_intf * eintf, struct sel_event_record * evt) float trigger_reading = 0.0; float threshold_reading = 0.0; - if (evt == NULL) + if (!evt) return; if (evt->record_type == 0xf0) { @@ -246,7 +245,7 @@ log_event(struct ipmi_event_intf * eintf, struct sel_event_record * evt) sdr = ipmi_sdr_find_sdr_bynumtype(intf, evt->sel_type.standard_type.gen_id, evt->sel_type.standard_type.sensor_num, evt->sel_type.standard_type.sensor_type); - if (sdr == NULL) { + if (!sdr) { /* could not find matching SDR record */ if (desc) { lprintf(LOG_NOTICE, "%s%s sensor - %s", @@ -363,11 +362,11 @@ openipmi_enable_event_msg_buffer(struct ipmi_intf * intf) req.msg.cmd = 0x2f; /* Get BMC Global Enables */ rsp = intf->sendrecv(intf, &req); - if (rsp == NULL) { + if (!rsp) { lprintf(LOG_ERR, "Get BMC Global Enables command failed"); return -1; } - else if (rsp->ccode > 0) { + else if (rsp->ccode) { lprintf(LOG_ERR, "Get BMC Global Enables command failed: %s", val2str(rsp->ccode, completion_code_vals)); return -1; @@ -379,11 +378,11 @@ openipmi_enable_event_msg_buffer(struct ipmi_intf * intf) req.msg.data_len = 1; rsp = intf->sendrecv(intf, &req); - if (rsp == NULL) { + if (!rsp) { lprintf(LOG_ERR, "Set BMC Global Enables command failed"); return -1; } - else if (rsp->ccode > 0) { + else if (rsp->ccode) { lprintf(LOG_ERR, "Set BMC Global Enables command failed: %s", val2str(rsp->ccode, completion_code_vals)); return -1; @@ -423,7 +422,7 @@ static int openipmi_read(struct ipmi_event_intf * eintf) { struct ipmi_addr addr; - struct ipmi_recv recv; + struct ipmi_recv recv = {}; uint8_t data[80]; int rv; @@ -508,11 +507,11 @@ selwatch_get_data(struct ipmi_intf * intf, struct sel_data *data) req.msg.cmd = IPMI_CMD_GET_SEL_INFO; rsp = intf->sendrecv(intf, &req); - if (rsp == NULL) { + if (!rsp) { lprintf(LOG_ERR, "Get SEL Info command failed"); return 0; } - if (rsp->ccode > 0) { + if (rsp->ccode) { lprintf(LOG_ERR, "Get SEL Info command failed: %s", val2str(rsp->ccode, completion_code_vals)); return 0; @@ -579,7 +578,7 @@ selwatch_setup(struct ipmi_event_intf * eintf) /* save current last record ID */ selwatch_lastid = selwatch_get_lastid(eintf->intf); lprintf(LOG_DEBUG, "Current SEL lastid is %04x", selwatch_lastid); - /* display alert/warning immediatly as startup if relevant */ + /* display alert/warning immediately as startup if relevant */ if (selwatch_pctused >= WARNING_THRESHOLD) { lprintf(LOG_WARNING, "SEL buffer used at %d%%, please consider clearing the SEL buffer", selwatch_pctused); } @@ -683,7 +682,7 @@ selwatch_wait(struct ipmi_event_intf * eintf) /*************************************************************************/ static void -ipmievd_cleanup(int signal) +ipmievd_cleanup(int __UNUSED__(signal)) { struct stat st1; @@ -706,32 +705,32 @@ ipmievd_main(struct ipmi_event_intf * eintf, int argc, char ** argv) sprintf(pidfile, "%s%d", DEFAULT_PIDFILE, eintf->intf->devnum); for (i = 0; i < argc; i++) { - if (strncasecmp(argv[i], "help", 4) == 0) { + if (strcasecmp(argv[i], "help") == 0) { ipmievd_usage(); return 0; } - if (strncasecmp(argv[i], "daemon", 6) == 0) { + if (strcasecmp(argv[i], "daemon") == 0) { daemon = 1; } - else if (strncasecmp(argv[i], "nodaemon", 8) == 0) { + else if (strcasecmp(argv[i], "nodaemon") == 0) { daemon = 0; } - else if (strncasecmp(argv[i], "daemon=", 7) == 0) { - if (strncasecmp(argv[i]+7, "on", 2) == 0 || - strncasecmp(argv[i]+7, "yes", 3) == 0) + else if (strcasecmp(argv[i], "daemon=") == 0) { + if (strcasecmp(argv[i]+7, "on") == 0 || + strcasecmp(argv[i]+7, "yes") == 0) daemon = 1; - else if (strncasecmp(argv[i]+7, "off", 3) == 0 || - strncasecmp(argv[i]+7, "no", 2) == 0) + else if (strcasecmp(argv[i]+7, "off") == 0 || + strcasecmp(argv[i]+7, "no") == 0) daemon = 0; } - else if (strncasecmp(argv[i], "timeout=", 8) == 0) { + else if (strcasecmp(argv[i], "timeout=") == 0) { if ( (str2int(argv[i]+8, &selwatch_timeout) != 0) || selwatch_timeout < 0) { lprintf(LOG_ERR, "Invalid input given or out of range for time-out."); return (-1); } } - else if (strncasecmp(argv[i], "pidfile=", 8) == 0) { + else if (strcasecmp(argv[i], "pidfile=") == 0) { memset(pidfile, 0, 64); strncpy(pidfile, argv[i]+8, __min(strlen((const char *)(argv[i]+8)), 63)); @@ -765,7 +764,7 @@ ipmievd_main(struct ipmi_event_intf * eintf, int argc, char ** argv) umask(022); fp = ipmi_open_file_write(pidfile); - if (fp == NULL) { + if (!fp) { /* Failed to get fp on PID file -> exit. */ log_halt(); log_init("ipmievd", daemon, verbose); @@ -796,7 +795,7 @@ ipmievd_main(struct ipmi_event_intf * eintf, int argc, char ** argv) /* call event handler setup routine */ - if (eintf->setup != NULL) { + if (eintf->setup) { rc = eintf->setup(eintf); if (rc < 0) { lprintf(LOG_ERR, "Error setting up Event Interface %s", eintf->name); @@ -807,7 +806,7 @@ ipmievd_main(struct ipmi_event_intf * eintf, int argc, char ** argv) lprintf(LOG_NOTICE, "Waiting for events..."); /* now launch event wait loop */ - if (eintf->wait != NULL) { + if (eintf->wait) { rc = eintf->wait(eintf); if (rc < 0) { lprintf(LOG_ERR, "Error waiting for events!"); @@ -824,14 +823,14 @@ ipmievd_sel_main(struct ipmi_intf * intf, int argc, char ** argv) struct ipmi_event_intf * eintf; eintf = ipmi_event_intf_load("sel"); - if (eintf == NULL) { + if (!eintf) { lprintf(LOG_ERR, "Unable to load event interface"); return -1; } eintf->intf = intf; - if (intf->session != NULL) { + if (intf->session) { snprintf(eintf->prefix, strlen((const char *)intf->ssn_params.hostname) + 3, "%s: ", intf->ssn_params.hostname); @@ -846,13 +845,13 @@ ipmievd_open_main(struct ipmi_intf * intf, int argc, char ** argv) struct ipmi_event_intf * eintf; /* only one interface works for this */ - if (strncmp(intf->name, "open", 4) != 0) { + if (strcmp(intf->name, "open")) { lprintf(LOG_ERR, "Invalid Interface for OpenIPMI Event Handler: %s", intf->name); return -1; } eintf = ipmi_event_intf_load("open"); - if (eintf == NULL) { + if (!eintf) { lprintf(LOG_ERR, "Unable to load event interface"); return -1; } @@ -864,7 +863,7 @@ ipmievd_open_main(struct ipmi_intf * intf, int argc, char ** argv) struct ipmi_cmd ipmievd_cmd_list[] = { #ifdef IPMI_INTF_OPEN - { ipmievd_open_main, "open", "Use OpenIPMI for asyncronous notification of events" }, + { ipmievd_open_main, "open", "Use OpenIPMI for asynchronous notification of events" }, #endif { ipmievd_sel_main, "sel", "Poll SEL for notification of events" }, { NULL } |