can-utils/lib: fix build issues introduced with sprintf_can_error_frame()

Signed-off-by: Wolfgang Grandegger <wg@grandegger.com>
pull/7/head
Wolfgang Grandegger 2011-02-14 16:10:39 +00:00
parent 796475677a
commit 71bcd74a7d
2 changed files with 12 additions and 12 deletions

22
lib.c
View File

@ -317,7 +317,7 @@ static const char *error_classes[] = {
"no-acknowledgement-on-tx", "no-acknowledgement-on-tx",
"bus-off", "bus-off",
"bus-error", "bus-error",
"restarted-from-bus-off", "restarted-after-bus-off",
}; };
static const char *controller_problems[] = { static const char *controller_problems[] = {
@ -379,8 +379,8 @@ static const char *protocol_violation_locations[] = {
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
#endif #endif
static int sprintf_error_data(char *buf, size_t len, uint8_t err, static int snprintf_error_data(char *buf, size_t len, uint8_t err,
const char **arr, int arr_len) const char **arr, int arr_len)
{ {
int i, n = 0, count = 0; int i, n = 0, count = 0;
@ -399,14 +399,14 @@ static int sprintf_error_data(char *buf, size_t len, uint8_t err,
return n; return n;
} }
static int sprintf_error_lostarb(char *buf, size_t len, struct can_frame *cf) static int snprintf_error_lostarb(char *buf, size_t len, struct can_frame *cf)
{ {
if (len <= 0) if (len <= 0)
return 0; return 0;
return snprintf(buf, len, "{at bit %d}", cf->data[0]); return snprintf(buf, len, "{at bit %d}", cf->data[0]);
} }
static int sprintf_error_ctrl(char *buf, size_t len, struct can_frame *cf) static int snprintf_error_ctrl(char *buf, size_t len, struct can_frame *cf)
{ {
int n = 0; int n = 0;
@ -414,7 +414,7 @@ static int sprintf_error_ctrl(char *buf, size_t len, struct can_frame *cf)
return 0; return 0;
n += snprintf(buf + n, len - n, "{"); n += snprintf(buf + n, len - n, "{");
n += sprintf_error_data(buf + n, len - n, cf->data[1], n += snprintf_error_data(buf + n, len - n, cf->data[1],
controller_problems, controller_problems,
ARRAY_SIZE(controller_problems)); ARRAY_SIZE(controller_problems));
n += snprintf(buf + n, len - n, "}"); n += snprintf(buf + n, len - n, "}");
@ -422,7 +422,7 @@ static int sprintf_error_ctrl(char *buf, size_t len, struct can_frame *cf)
return n; return n;
} }
static int sprintf_error_prot(char *buf, size_t len, struct can_frame *cf) static int snprintf_error_prot(char *buf, size_t len, struct can_frame *cf)
{ {
int n = 0; int n = 0;
@ -430,7 +430,7 @@ static int sprintf_error_prot(char *buf, size_t len, struct can_frame *cf)
return 0; return 0;
n += snprintf(buf + n, len - n, "{{"); n += snprintf(buf + n, len - n, "{{");
n += sprintf_error_data(buf + n, len - n, cf->data[2], n += snprintf_error_data(buf + n, len - n, cf->data[2],
protocol_violation_types, protocol_violation_types,
ARRAY_SIZE(protocol_violation_types)); ARRAY_SIZE(protocol_violation_types));
n += snprintf(buf + n, len - n, "}{"); n += snprintf(buf + n, len - n, "}{");
@ -469,12 +469,12 @@ void snprintf_can_error_frame(char *buf, size_t len, struct can_frame *cf,
n += snprintf(buf + n, len - n, "%s", sep); n += snprintf(buf + n, len - n, "%s", sep);
n += snprintf(buf + n, len - n, "%s", error_classes[i]); n += snprintf(buf + n, len - n, "%s", error_classes[i]);
if (mask == CAN_ERR_LOSTARB) if (mask == CAN_ERR_LOSTARB)
n += sprintf_error_lostarb(buf + n, len - n, n += snprintf_error_lostarb(buf + n, len - n,
cf); cf);
if (mask == CAN_ERR_CRTL) if (mask == CAN_ERR_CRTL)
n += sprintf_error_ctrl(buf + n, len - n, cf); n += snprintf_error_ctrl(buf + n, len - n, cf);
if (mask == CAN_ERR_PROT) if (mask == CAN_ERR_PROT)
n += sprintf_error_prot(buf + n, len - n, cf); n += snprintf_error_prot(buf + n, len - n, cf);
classes++; classes++;
} }
} }

2
lib.h
View File

@ -148,7 +148,7 @@ void sprint_long_canframe(char *buf , struct can_frame *cf, int view);
* *
*/ */
void snprintf_can_error_frame(char *buf, int len, struct can_frame *cf, void snprintf_can_error_frame(char *buf, size_t len, struct can_frame *cf,
char *sep); char *sep);
/* /*
* Creates a CAN error frame output in user readable format. * Creates a CAN error frame output in user readable format.