diff --git a/canerrsim.c b/canerrsim.c index 280acf6..8c6caf3 100644 --- a/canerrsim.c +++ b/canerrsim.c @@ -134,21 +134,14 @@ void __attribute__((format (printf, 1, 2))) err_exit(const char *format, ...) exit(EXIT_FAILURE); } -void show_custom_format_and_exit(const char *param, const char *format) -{ - char str_buf[80]; - sprintf(str_buf, format, param); - err_exit("%s", str_buf); -} - void show_invalid_option(const char *option) { - show_custom_format_and_exit(option, "Error: Invalid option %s\n"); + err_exit("Error: Invalid option %s\n", option); } void show_err_and_exit(const char *err_type) { - show_custom_format_and_exit(err_type, "Error: You can only have one %s parameter!\n"); + err_exit("Error: You can only have one %s parameter!\n", err_type); } void show_loc_err_and_exit() @@ -182,7 +175,6 @@ int main(int argc, char *argv[]) struct ifreq ifr; struct can_frame frame; bool show_bits = false, location_processed = false, transceiver_processed = false, arbitration_processed = false; - char tmp_str[256]; printf("CAN Sockets Error Messages Simulator\n"); if (argc < 3) @@ -547,10 +539,8 @@ int main(int argc, char *argv[]) // set interface name strcpy(ifr.ifr_name, argv[1]); // can0, vcan0... - if (ioctl(sock, SIOCGIFINDEX, &ifr) < 0) { - sprintf(tmp_str, "Error setting CAN interface name %s", argv[1]); - err_exit(tmp_str); - } + if (ioctl(sock, SIOCGIFINDEX, &ifr) < 0) + err_exit("Error setting CAN interface name %s\n", argv[1]); // bind socket to the CAN interface addr.can_family = AF_CAN;