jlink: remove superfluous indentation
authorZachary T Welch <zw@superlucidity.net>
Thu, 19 Nov 2009 20:41:25 +0000 (12:41 -0800)
committerZachary T Welch <zw@superlucidity.net>
Tue, 24 Nov 2009 15:30:20 +0000 (07:30 -0800)
Rewrite logic to remove indentation in jlink_usb_open, in prep
for further surgery.

src/jtag/jlink.c

index ebc9acd26c060d4cc8d2338f1502bbe2f71d057d..8f1d112d63135707f9fe89fcbd3c1edb02617a83 100644 (file)
@@ -864,78 +864,81 @@ static struct jlink* jlink_usb_open()
 
        result->usb_handle = usb_open(dev);
 
-       if (result->usb_handle)
-       {
+       if (NULL == result->usb_handle)
+               return NULL;
 
-               /* BE ***VERY CAREFUL*** ABOUT MAKING CHANGES IN THIS AREA!!!!!!!!!!!
-                * The behavior of libusb is not completely consistent across Windows, Linux, and Mac OS X platforms.  The actions taken
-                * in the following compiler conditionals may not agree with published documentation for libusb, but were found
-                * to be necessary through trials and tribulations.  Even little tweaks can break one or more platforms, so if you do make changes
-                * test them carefully on all platforms before committing them!
-                */
+       /* BE ***VERY CAREFUL*** ABOUT MAKING CHANGES IN THIS
+        * AREA!!!!!!!!!!!  The behavior of libusb is not completely
+        * consistent across Windows, Linux, and Mac OS X platforms.
+        * The actions taken in the following compiler conditionals may
+        * not agree with published documentation for libusb, but were
+        * found to be necessary through trials and tribulations.  Even
+        * little tweaks can break one or more platforms, so if you do
+        * make changes test them carefully on all platforms before
+        * committing them!
+        */
 
 #if IS_WIN32 == 0
 
-               usb_reset(result->usb_handle);
+       usb_reset(result->usb_handle);
 
 #if IS_DARWIN == 0
 
-               int timeout = 5;
+       int timeout = 5;
 
-               /* reopen jlink after usb_reset
-                * on win32 this may take a second or two to re-enumerate */
-               while ((dev = find_jlink_device()) == NULL)
-               {
-                       usleep(1000);
-                       timeout--;
-                       if (!timeout) {
-                               break;
-                       }
+       /* reopen jlink after usb_reset
+        * on win32 this may take a second or two to re-enumerate */
+       while ((dev = find_jlink_device()) == NULL)
+       {
+               usleep(1000);
+               timeout--;
+               if (!timeout) {
+                       break;
                }
+       }
 
-               if (dev == NULL)
-               {
-                       free(result);
-                       return NULL;
-               }
+       if (dev == NULL)
+       {
+               free(result);
+               return NULL;
+       }
 
-               result->usb_handle = usb_open(dev);
+       result->usb_handle = usb_open(dev);
 #endif
 
 #endif
 
-               if (result->usb_handle)
-               {
-                       /* usb_set_configuration required under win32 */
-                       usb_set_configuration(result->usb_handle, dev->config[0].bConfigurationValue);
-                       usb_claim_interface(result->usb_handle, 0);
+       if (NULL == result->usb_handle)
+       {
+               free(result);
+               return NULL;
+       }
+
+       /* usb_set_configuration required under win32 */
+       usb_set_configuration(result->usb_handle, dev->config[0].bConfigurationValue);
+       usb_claim_interface(result->usb_handle, 0);
 
 #if 0
-                       /*
-                        * This makes problems under Mac OS X. And is not needed
-                        * under Windows. Hopefully this will not break a linux build
-                        */
-                       usb_set_altinterface(result->usb_handle, 0);
+       /*
+        * This makes problems under Mac OS X. And is not needed
+        * under Windows. Hopefully this will not break a linux build
+        */
+       usb_set_altinterface(result->usb_handle, 0);
 #endif
-                       struct usb_interface *iface = dev->config->interface;
-                       struct usb_interface_descriptor *desc = iface->altsetting;
-                       for (int i = 0; i < desc->bNumEndpoints; i++)
-                       {
-                               uint8_t epnum = desc->endpoint[i].bEndpointAddress;
-                               bool is_input = epnum & 0x80;
-                               LOG_DEBUG("usb ep %s %02x", is_input ? "in" : "out", epnum);
-                               if (is_input)
-                                       jlink_read_ep = epnum;
-                               else
-                                       jlink_write_ep = epnum;
-                       }
-
-                       return result;
-               }
+       struct usb_interface *iface = dev->config->interface;
+       struct usb_interface_descriptor *desc = iface->altsetting;
+       for (int i = 0; i < desc->bNumEndpoints; i++)
+       {
+               uint8_t epnum = desc->endpoint[i].bEndpointAddress;
+               bool is_input = epnum & 0x80;
+               LOG_DEBUG("usb ep %s %02x", is_input ? "in" : "out", epnum);
+               if (is_input)
+                       jlink_read_ep = epnum;
+               else
+                       jlink_write_ep = epnum;
        }
 
-       free(result);
-       return NULL;
+       return result;
 }
 
 static void jlink_usb_close(struct jlink *jlink)

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)