[ Please keep discussion on list ]

On Tue, 2005-02-08 at 14:37 +0100, Bernhard Fischer wrote:
> Sorry to address you..
> 
> Why don't you place the DEBUG #ifdefs like below thus saving a couple of
> IMHO unneeded instructions?
> Just curious, but TIA for clarification.

That block of code is pretty much copied directly from ether.c.  I don't
see why I couldn't add in what you are have suggested, but I am not sure
if it really that big a deal.

-tduffy

> >diff -Nur net-tools-1.60/lib/ib.c net-tools-1.60-ib/lib/ib.c
> >--- net-tools-1.60/lib/ib.c  1969-12-31 16:00:00.000000000 -0800
> >+++ net-tools-1.60-ib/lib/ib.c       2005-02-07 12:55:04.635559244 -0800
> [snip]
> >+static int in_ib(char *bufp, struct sockaddr *sap)
> [snip]
> >+    while ((*bufp != '\0') && (i < INFINIBAND_ALEN)) {
> >+    val = 0;
> >+    c = *bufp++;
> >+    if (isdigit(c))
> >+        val = c - '0';
> >+    else if (c >= 'a' && c <= 'f')
> >+        val = c - 'a' + 10;
> >+    else if (c >= 'A' && c <= 'F')
> >+        val = c - 'A' + 10;
> >+    else {
> >+#ifdef DEBUG
> >+        fprintf(stderr, _("in_ib(%s): invalid infiniband address!\n"), 
> >orig);
> >+#endif
> >+        errno = EINVAL;
> >+        return (-1);
> >+    }
> >+    val <<= 4;
> >+    c = *bufp;
> >+    if (isdigit(c))
> >+        val |= c - '0';
> >+    else if (c >= 'a' && c <= 'f')
> >+        val |= c - 'a' + 10;
> >+    else if (c >= 'A' && c <= 'F')
> >+        val |= c - 'A' + 10;
> >+    else if (c == ':' || c == 0)
> >+        val >>= 4;
> >+    else {
> >+#ifdef DEBUG
> >+        fprintf(stderr, _("in_ib(%s): invalid infiniband address!\n"), 
> >orig);
> >+#endif
> >+        errno = EINVAL;
> >+        return (-1);
> >+    }
> >+    if (c != 0)
> >+        bufp++;
> >+    *ptr++ = (unsigned char) (val & 0377);
> >+    i++;
> >+
> >+    /* We might get a semicolon here - not required. */
> >+    if (*bufp == ':') {
> +>+#ifdef DEBUG
> >+        if (i == INFINIBAND_ALEN) {
> ->+#ifdef DEBUG
> >+            fprintf(stderr, _("in_ib(%s): trailing : ignored!\n"),
> >+                    orig)
> ->+#endif
> >+                ;           /* nothing */
> >+        }
> +>+#endif
> >+        bufp++;
> >+    }
> >+    }
> >+
> +>+#ifdef DEBUG
> >+    /* That's it.  Any trailing junk? */
> >+    if ((i == INFINIBAND_ALEN) && (*bufp != '\0')) {
> ->+#ifdef DEBUG
> >+    fprintf(stderr, _("in_ib(%s): trailing junk!\n"), orig);
> >+    errno = EINVAL;
> >+    return (-1);
> ->+#endif
> >+    }
> ->+#ifdef DEBUG
> >+    fprintf(stderr, "in_ib(%s): %s\n", orig, pr_ib(sap->sa_data));
> >+#endif
> >+
> >+    return (0);
> >+}

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
openib-general mailing list
[email protected]
http://openib.org/mailman/listinfo/openib-general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

Reply via email to