diff options
Diffstat (limited to 'src/plugins/serial/serial_terminal.c')
-rw-r--r-- | src/plugins/serial/serial_terminal.c | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/src/plugins/serial/serial_terminal.c b/src/plugins/serial/serial_terminal.c index 4459f64..58bca17 100644 --- a/src/plugins/serial/serial_terminal.c +++ b/src/plugins/serial/serial_terminal.c @@ -29,7 +29,6 @@ * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, * EVEN IF PPS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. */ -#define _GNU_SOURCE 1 /* Serial Interface, Terminal Mode plugin. */ @@ -150,7 +149,7 @@ ipmi_serial_term_open(struct ipmi_intf * intf) struct termios ti; unsigned int rate = 9600; char *p; - int i; + size_t i; if (!intf->devfile) { lprintf(LOG_ERR, "Serial device is not specified"); @@ -189,12 +188,12 @@ ipmi_serial_term_open(struct ipmi_intf * intf) return -1; } - for (i = 0; i < sizeof(rates) / sizeof(rates[0]); i++) { + for (i = 0; i < ARRAY_SIZE(rates); i++) { if (rates[i].baudrate == rate) { break; } } - if (i >= sizeof(rates) / sizeof(rates[0])) { + if (i >= ARRAY_SIZE(rates)) { lprintf(LOG_ERR, "Unsupported baud rate %i specified", rate); return -1; } @@ -354,7 +353,7 @@ serial_flush(struct ipmi_intf * intf) /* * Receive IPMI response from the device * Len: buffer size - * Returns: -1 or response lenth on success + * Returns: -1 or response length on success */ static int recv_response(struct ipmi_intf * intf, unsigned char *data, int len) @@ -395,7 +394,7 @@ recv_response(struct ipmi_intf * intf, unsigned char *data, int len) *pp = 0; /* was it an error? */ - if (strncmp(p, "ERR ", 4) == 0) { + if (!strcmp(p, "ERR ")) { serial_write_line(intf, "\r\r\r\r"); sleep(1); serial_flush(intf); @@ -474,18 +473,7 @@ serial_term_build_msg(const struct ipmi_intf * intf, struct serial_term_hdr * term_hdr = (struct serial_term_hdr *) msg; struct ipmi_send_message_rq * outer_rq = NULL; struct ipmi_send_message_rq * inner_rq = NULL; - int bridging_level; - - /* acquire bridging level */ - if (intf->target_addr && intf->target_addr != intf->my_addr) { - if (intf->transit_addr != 0) { - bridging_level = 2; - } else { - bridging_level = 1; - } - } else { - bridging_level = 0; - } + int bridging_level = ipmi_intf_get_bridging_level(intf); /* check overall packet length */ if(req->msg.data_len + 3 + bridging_level * 8 > max_len) { @@ -636,7 +624,7 @@ serial_term_send_msg(struct ipmi_intf * intf, uint8_t * msg, int msg_len) /* body */ for (i = 0; i < msg_len; i++) { - buf += sprintf( buf, "%02x", msg[i]); + buf += sprintf((char*) buf, "%02x", msg[i]); } /* stop character */ @@ -715,11 +703,13 @@ serial_term_wait_response(struct ipmi_intf * intf, /* * Get message from receive message queue + * + * Note: Kept max_len in case it's useful later. */ static int serial_term_get_message(struct ipmi_intf * intf, struct serial_term_request_ctx * req_ctx, - uint8_t * msg, size_t max_len) + uint8_t * msg, size_t __UNUSED__(max_len)) { uint8_t data[IPMI_SERIAL_MAX_RESPONSE]; struct serial_term_request_ctx tmp_ctx; |