From b25024e71f11688875ed2e1d0600b2b37ddfce19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?King=20K=C3=A9vin?= Date: Mon, 24 Oct 2022 14:44:26 +0200 Subject: [PATCH] minor code reformatting --- .../device/dfu_freertos/src/usb_descriptors.c | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/examples/device/dfu_freertos/src/usb_descriptors.c b/examples/device/dfu_freertos/src/usb_descriptors.c index 237fcd821..bafe96bd6 100644 --- a/examples/device/dfu_freertos/src/usb_descriptors.c +++ b/examples/device/dfu_freertos/src/usb_descriptors.c @@ -136,35 +136,31 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid) size_t chr_count; - if ( index == 0) - { + if (index == 0) { // get language (not a string) memcpy(&_desc_str[1], string_desc_arr[0], 2); chr_count = 1; - } - else - { + } else { // get other description (strings) // Note: the 0xEE index string is a Microsoft OS 1.0 Descriptors. // https://docs.microsoft.com/en-us/windows-hardware/drivers/usbcon/microsoft-defined-usb-descriptors - if ( !(index < sizeof(string_desc_arr)/sizeof(string_desc_arr[0])) ) return NULL; + if ( !(index < sizeof(string_desc_arr)/sizeof(string_desc_arr[0])) ) return NULL; // check if requested descriptor exists + const char* str = string_desc_arr[index]; // load requested string - const char* str = string_desc_arr[index]; - - // Cap at max char + // check string length chr_count = strlen(str); - if ( chr_count > 31 ) { + if ( chr_count > 31 ) { // cap at max char chr_count = 31; } - // Convert ASCII string into UTF-16 - for(uint8_t i=0; i