From: Andrew Tannenbaum <trb@domain.hid>
To: xenomai@xenomai.org
Subject: [Xenomai-help] odd code for loopback option in /src/utils/can/rtcansend.c
Date: Thu, 18 Aug 2011 14:58:17 -0400 [thread overview]
Message-ID: <4E4D60C9.1020409@domain.hid> (raw)
In xenomai-2.5.5.2/src/utils/can/rtcansend.c, the code that handles
local loopback mode looks like this:
static void print_usage(char *prg)
{
...
" -L, --loopback=0|1 switch local loopback off or on\n"
...
}
static int loopback=-1;
switch (opt) {
...
case 'L':
loopback = strtoul(optarg, NULL, 0);
break;
...
}
...
if (loopback >= 0) {
ret = rt_dev_setsockopt(s, SOL_CAN_RAW, CAN_RAW_LOOPBACK,
&loopback, sizeof(loopback));
if (ret < 0) {
fprintf(stderr, "rt_dev_setsockopt: %s\n", strerror(-ret));
goto failure;
}
if (verbose)
printf("Using loopback=%d\n", loopback);
}
It looks like the default value for loopback is -1, and if you set it to
0 or 1, it turns loopback on, which seems strange. I don't understand
rt_dev_setsockopt() fully, so I'm not sure if it's a bug - I don't know
if -1 and 0 and 1 are three separate loopback states, but I think it
merits attention. I think either the code is wrong or the help string
and man page are not clear.
-Andy
next reply other threads:[~2011-08-18 18:58 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-18 18:58 Andrew Tannenbaum [this message]
2011-08-18 19:19 ` [Xenomai-help] odd code for loopback option in /src/utils/can/rtcansend.c Andrew Tannenbaum
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4E4D60C9.1020409@domain.hid \
--to=trb@domain.hid \
--cc=xenomai@xenomai.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.