summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Beisert <j.beisert@pengutronix.de>2007-10-02 16:26:54 +0000
committerJuergen Beisert <j.beisert@pengutronix.de>2007-10-02 16:26:54 +0000
commit0ca51a00c7b36d4cf7d32e9a22cc48949bc990f2 (patch)
tree5b19e0ebf28a2082ef956c1f355e217a55bdc7c8
parent4efccca79e450873de1ed47a91fe7476d79f72e6 (diff)
downloadcanutils-0ca51a00c7b36d4cf7d32e9a22cc48949bc990f2.tar.gz
for tests
git-svn-id: https://iocaste.extern.pengutronix.de/svn/canutils/trunks/canutils-2.0-trunk@77 5fd5a299-6ef2-0310-aa18-8b01d7c39d8c
-rw-r--r--src/canconfig.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/canconfig.c b/src/canconfig.c
index 5482948..5a783b0 100644
--- a/src/canconfig.c
+++ b/src/canconfig.c
@@ -149,15 +149,21 @@ static void tweak_a_bitrate(uint32_t bit_rate, uint32_t brp,
uint32_t prop_seg, uint32_t phase_seg1, uint32_t phase_seg2,
uint32_t sjw)
{
- struct can_bit_time_custom *bit_time = (can_bit_time_custom *)&ifr.ifr_ifru;
+ struct can_bit_time_custom *bit_time = (struct can_bit_time_custom *)&ifr.ifr_ifru;
int i;
+ if (sizeof(struct can_bit_time_custom) > sizeof(ifr.ifr_ifru)) {
+ printf("Error can_bit_time_custom to large! (%d, %d)",
+ sizeof (struct can_bit_time_custom), sizeof(ifr.ifr_ifru));
+ exit(EXIT_FAILURE);
+ }
+
bit_time->bit_rate = bit_rate;
bit_time->brp = brp;
bit_time->prop_seg = prop_seg;
bit_time->phase_seg1 = phase_seg1;
bit_time->phase_seg2 = phase_seg2;
- bit_time->sjw = sjw
+ bit_time->sjw = sjw;
i = ioctl(s, SIOCSCANDEDBITTIME, &ifr);
if (i < 0) {
@@ -193,7 +199,7 @@ static void tweak_from_command_line(int argc, char *argv[])
static void tweak_from_config_file(int argc, char *argv[])
{
FILE *config_file;
- char file_name[MAX_PATH];
+ char file_name[PATH_MAX];
int first_char,cnt,line = 1;
uint32_t bit_rate;
uint32_t brp;
@@ -205,12 +211,13 @@ static void tweak_from_config_file(int argc, char *argv[])
sprintf(file_name, CONFIG_FILE_NAME_SP, argv[1]);
config_file = fopen(file_name, "r");
if (config_file == NULL) {
- sprintf(file_name, CONFIG_FILE_NAME,);
+ sprintf(file_name, CONFIG_FILE_NAME);
config_file = fopen(file_name, "r");
if (config_file == NULL) {
perror("Config file (" CONFIG_FILE_NAME ")");
exit(EXIT_FAILURE);
}
+ }
while(!feof(config_file)) {
first_char = fgetc(config_file);
@@ -313,7 +320,7 @@ int main(int argc, char *argv[])
{
if ((argc < 2) || !strcmp(argv[1], "--help"))
help();
-#if 0
+#if 1
if ((s = socket(AF_CAN, SOCK_RAW, CAN_RAW)) < 0) {
perror("socket");
exit(EXIT_FAILURE);