summaryrefslogtreecommitdiff
path: root/lib/ipmi_raw.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2022-09-10 15:44:42 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2022-09-10 15:44:42 +0200
commitd83fb6dd0cdb8d4509fda0c6e77bbeb0fcd018a8 (patch)
tree2599d2b8a9e660bff139cbd2a32d777ad30e0c9d /lib/ipmi_raw.c
parent36a24e9032591da8cc7688f69e7e9f5f41ffe4ab (diff)
parenta9ee361f27e0439530387765924574e5358c8a5c (diff)
Update upstream source from tag 'upstream/1.8.19'
Update to upstream version '1.8.19' with Debian dir 820184ee2ea8eb8c4a7769d0a89d5236e5775134
Diffstat (limited to 'lib/ipmi_raw.c')
-rw-r--r--lib/ipmi_raw.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/lib/ipmi_raw.c b/lib/ipmi_raw.c
index 92c0177..a8a42a0 100644
--- a/lib/ipmi_raw.c
+++ b/lib/ipmi_raw.c
@@ -101,11 +101,11 @@ ipmi_master_write_read(struct ipmi_intf * intf, uint8_t bus, uint8_t addr,
}
rsp = intf->sendrecv(intf, &req);
- if (rsp == NULL) {
+ if (!rsp) {
lprintf(LOG_ERR, "I2C Master Write-Read command failed");
return NULL;
}
- else if (rsp->ccode > 0) {
+ else if (rsp->ccode) {
switch (rsp->ccode) {
case 0x81:
lprintf(LOG_ERR, "I2C Master Write-Read command failed: Lost Arbitration");
@@ -145,7 +145,7 @@ ipmi_rawspd_main(struct ipmi_intf * intf, int argc, char ** argv)
memset(spd_data, 0, RAW_SPD_SIZE);
- if (argc < 2 || strncmp(argv[0], "help", 4) == 0) {
+ if (argc < 2 || !strcmp(argv[0], "help")) {
lprintf(LOG_NOTICE, "usage: spd <i2cbus> <i2caddr> [channel] [maxread]");
return 0;
}
@@ -171,7 +171,7 @@ ipmi_rawspd_main(struct ipmi_intf * intf, int argc, char ** argv)
for (i = 0; i < RAW_SPD_SIZE; i+= msize) {
rsp = ipmi_master_write_read(intf, i2cbus, i2caddr,
(uint8_t *)&i, 1, msize );
- if (rsp == NULL) {
+ if (!rsp) {
lprintf(LOG_ERR, "Unable to perform I2C Master Write-Read");
return -1;
}
@@ -190,6 +190,9 @@ static void rawi2c_usage(void)
lprintf(LOG_NOTICE, " chan=0 is default, bus= must be specified to use chan=");
}
+#define BUS_KW "bus="
+#define CHAN_KW "chan="
+
int
ipmi_rawi2c_main(struct ipmi_intf * intf, int argc, char ** argv)
{
@@ -203,25 +206,25 @@ ipmi_rawi2c_main(struct ipmi_intf * intf, int argc, char ** argv)
int i = 0;
/* handle bus= argument */
- if (argc > 2 && strncmp(argv[0], "bus=", 4) == 0) {
+ if (argc > 2 && !strncmp(argv[0], BUS_KW, strlen(BUS_KW))) {
i = 1;
- if (strncmp(argv[0], "bus=public", 10) == 0)
+ if (!strcmp(argv[0], BUS_KW "public"))
bus = 0;
- else if (sscanf(argv[0], "bus=%u", &rbus) == 1)
+ else if (sscanf(argv[0], BUS_KW "%u", &rbus) == 1)
bus = ((rbus & 7) << 1) | 1;
else
bus = 0;
/* handle channel= argument
* the bus= argument must be supplied first on command line */
- if (argc > 3 && strncmp(argv[1], "chan=", 5) == 0) {
+ if (argc > 3 && !strncmp(argv[1], CHAN_KW, strlen(CHAN_KW))) {
i = 2;
- if (sscanf(argv[1], "chan=%u", &rbus) == 1)
+ if (sscanf(argv[1], CHAN_KW "%u", &rbus) == 1)
bus |= rbus << 4;
}
}
- if ((argc-i) < 2 || strncmp(argv[0], "help", 4) == 0) {
+ if ((argc - i) < 2 || !strcmp(argv[0], "help")) {
rawi2c_usage();
return 0;
}
@@ -259,7 +262,7 @@ ipmi_rawi2c_main(struct ipmi_intf * intf, int argc, char ** argv)
printbuf(wdata, wsize, "WRITE DATA");
rsp = ipmi_master_write_read(intf, bus, i2caddr, wdata, wsize, rsize);
- if (rsp == NULL) {
+ if (!rsp) {
lprintf(LOG_ERR, "Unable to perform I2C Master Write-Read");
return -1;
}
@@ -322,7 +325,7 @@ ipmi_raw_main(struct ipmi_intf * intf, int argc, char ** argv)
int i;
uint8_t data[256];
- if (argc == 1 && strncmp(argv[0], "help", 4) == 0) {
+ if (argc == 1 && !strcmp(argv[0], "help")) {
ipmi_raw_help();
return 0;
}
@@ -379,13 +382,13 @@ ipmi_raw_main(struct ipmi_intf * intf, int argc, char ** argv)
rsp = intf->sendrecv(intf, &req);
- if (rsp == NULL) {
+ if (!rsp) {
lprintf(LOG_ERR, "Unable to send RAW command "
"(channel=0x%x netfn=0x%x lun=0x%x cmd=0x%x)",
intf->target_channel & 0x0f, req.msg.netfn, req.msg.lun, req.msg.cmd);
return -1;
}
- if (rsp->ccode > 0) {
+ if (rsp->ccode) {
lprintf(LOG_ERR, "Unable to send RAW command "
"(channel=0x%x netfn=0x%x lun=0x%x cmd=0x%x rsp=0x%x): %s",
intf->target_channel & 0x0f, req.msg.netfn, req.msg.lun, req.msg.cmd, rsp->ccode,
@@ -417,7 +420,7 @@ ipmi_raw_main(struct ipmi_intf * intf, int argc, char ** argv)
*/
int
is_valid_param(const char *input_param, uint8_t *uchr_ptr, const char *label) {
- if (input_param == NULL || label == NULL) {
+ if (!input_param || !label) {
lprintf(LOG_ERROR, "ERROR: NULL pointer passed.");
return (-1);
}