]> rtime.felk.cvut.cz Git - sojka/can-utils.git/blobdiff - cangw.c
slcanpty: fix wrong usage of nbytes variable
[sojka/can-utils.git] / cangw.c
diff --git a/cangw.c b/cangw.c
index d6e96682f9287b977627f12ffecbd9a8298d3701..18cc50cdb66fe2b6922fd784ac62771ee93e2e1c 100644 (file)
--- a/cangw.c
+++ b/cangw.c
@@ -1,7 +1,3 @@
-/*
- *  $Id$
- */
-
 /*
  * cangw.c - manage PF_CAN netlink gateway
  *
@@ -41,7 +37,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
  * DAMAGE.
  *
- * Send feedback to <socketcan-users@lists.berlios.de>
+ * Send feedback to <linux-can@vger.kernel.org>
  *
  */
 
@@ -328,8 +324,7 @@ int parse_mod(char *optarg, struct modattr *modmsg)
                ptr++;
        }
 
-       if (sscanf(++ptr, "%lx.%hhx.%16s",
-                  (long unsigned int *)&modmsg->cf.can_id,
+       if (sscanf(++ptr, "%x.%hhx.%16s", &modmsg->cf.can_id,
                   (unsigned char *)&modmsg->cf.can_dlc, hexdata) != 3)
                return 5;
 
@@ -593,13 +588,11 @@ int main(int argc, char **argv)
                        break;
 
                case 'f':
-                       if (sscanf(optarg, "%lx:%lx",
-                                  (long unsigned int *)&filter.can_id, 
-                                  (long unsigned int *)&filter.can_mask) == 2) {
+                       if (sscanf(optarg, "%x:%x", &filter.can_id,
+                                  &filter.can_mask) == 2) {
                                have_filter = 1;
-                       } else if (sscanf(optarg, "%lx~%lx",
-                                         (long unsigned int *)&filter.can_id, 
-                                         (long unsigned int *)&filter.can_mask) == 2) {
+                       } else if (sscanf(optarg, "%x~%x", &filter.can_id,
+                                         &filter.can_mask) == 2) {
                                filter.can_id |= CAN_INV_FILTER;
                                have_filter = 1;
                        } else {
@@ -672,6 +665,11 @@ int main(int argc, char **argv)
                exit(1);
        }
 
+       if (!modidx && (have_cs_crc8 || have_cs_xor)) {
+               printf("-c or -x can only be used in conjunction with -m\n");
+               exit(1);
+       }
+
        s = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
 
        switch (cmd) {