From a9ee361f27e0439530387765924574e5358c8a5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sat, 10 Sep 2022 15:44:41 +0200 Subject: New upstream version 1.8.19 --- lib/ipmi_tsol.c | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) (limited to 'lib/ipmi_tsol.c') diff --git a/lib/ipmi_tsol.c b/lib/ipmi_tsol.c index d89bcfd..7cf1bcc 100644 --- a/lib/ipmi_tsol.c +++ b/lib/ipmi_tsol.c @@ -29,7 +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 _DEFAULT_SOURCE #include #include @@ -104,11 +103,11 @@ ipmi_tsol_command(struct ipmi_intf *intf, char *recvip, int port, data[5] = (port & 0xff); rsp = intf->sendrecv(intf, &req); - if (rsp == NULL) { + if (!rsp) { lprintf(LOG_ERR, "Unable to perform TSOL command"); return (-1); } - if (rsp->ccode > 0) { + if (rsp->ccode) { lprintf(LOG_ERR, "Unable to perform TSOL command: %s", val2str(rsp->ccode, completion_code_vals)); return (-1); @@ -149,11 +148,11 @@ ipmi_tsol_send_keystroke(struct ipmi_intf *intf, char *buff, int length) rsp = intf->sendrecv(intf, &req); if (verbose) { - if (rsp == NULL) { + if (!rsp) { lprintf(LOG_ERR, "Unable to send keystroke"); return -1; } - if (rsp->ccode > 0) { + if (rsp->ccode) { lprintf(LOG_ERR, "Unable to send keystroke: %s", val2str(rsp->ccode, completion_code_vals)); return -1; @@ -377,12 +376,12 @@ ipmi_tsol_main(struct ipmi_intf *intf, int argc, char **argv) char out_buff[IPMI_BUF_SIZE * 8]; char buff[IPMI_BUF_SIZE + 4]; int fd_socket, result, i; - int out_buff_fill, in_buff_fill; + size_t out_buff_fill, in_buff_fill; int ip1, ip2, ip3, ip4; int read_only = 0, rows = 0, cols = 0; int port = IPMI_TSOL_DEF_PORT; - if (strlen(intf->name) < 3 || strncmp(intf->name, "lan", 3) != 0) { + if (strlen(intf->name) < 3 || strcmp(intf->name, "lan")) { lprintf(LOG_ERR, "Error: Tyan SOL is only available over lan interface"); return (-1); } @@ -398,17 +397,13 @@ ipmi_tsol_main(struct ipmi_intf *intf, int argc, char **argv) rows = ip1; } else if (sscanf(argv[i], "cols=%d", &ip1) == 1) { cols = ip1; - } else if (strlen(argv[i]) == 2 - && strncmp(argv[i], "ro", 2) == 0) { + } else if (!strcmp(argv[i], "ro")) { read_only = 1; - } else if (strlen(argv[i]) == 2 - && strncmp(argv[i], "rw", 2) == 0) { + } else if (!strcmp(argv[i], "rw")) { read_only = 0; - } else if (strlen(argv[i]) == 7 - && strncmp(argv[i], "altterm", 7) == 0) { + } else if (!strcmp(argv[i], "altterm")) { _altterm = 1; - } else if (strlen(argv[i]) == 4 - && strncmp(argv[i], "help", 4) == 0) { + } else if (!strcmp(argv[i], "help")) { print_tsol_usage(); return 0; } else { @@ -430,7 +425,7 @@ ipmi_tsol_main(struct ipmi_intf *intf, int argc, char **argv) if (result <= 0) { struct hostent *host = gethostbyname((const char *)intf->ssn_params.hostname); - if (host == NULL ) { + if (!host ) { lprintf(LOG_ERR, "Address lookup for %s failed", intf->ssn_params.hostname); return -1; @@ -460,7 +455,7 @@ ipmi_tsol_main(struct ipmi_intf *intf, int argc, char **argv) /* * retrieve local IP address if not supplied on command line */ - if (recvip == NULL) { + if (!recvip) { /* must connect first */ result = intf->open(intf); if (result < 0) { @@ -476,7 +471,7 @@ ipmi_tsol_main(struct ipmi_intf *intf, int argc, char **argv) } recvip = inet_ntoa(myaddr.sin_addr); - if (recvip == NULL) { + if (!recvip) { lprintf(LOG_ERR, "Unable to find local IP address"); close(fd_socket); return -1; @@ -539,7 +534,7 @@ ipmi_tsol_main(struct ipmi_intf *intf, int argc, char **argv) if ((fds[0].revents & POLLIN) && (sizeof(out_buff) > out_buff_fill)) { socklen_t sin_len = sizeof(sin); - int buff_size = sizeof(buff); + size_t buff_size = sizeof(buff); if ((sizeof(out_buff) - out_buff_fill + 4) < buff_size) { buff_size = (sizeof(out_buff) - out_buff_fill) + 4; if ((buff_size - 4) <= 0) { -- cgit v1.2.3