Skip to content

Conversation

@ndreys
Copy link

@ndreys ndreys commented Nov 15, 2025

It is useful to be able to set .ptr to point to a string obtained at runtime, so let's remove the second const qualifier so that the pointer itself can be adjusted.

It is useful to be able to set .ptr to point to a string obtained at
runtime, so let's remove the second const qualifier so that the
pointer itself can be adjusted.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
@zephyrbot zephyrbot added area: USB Universal Serial Bus size: XS A PR changing only a single line of code labels Nov 15, 2025
@sonarqubecloud
Copy link

@josuah
Copy link
Contributor

josuah commented Nov 15, 2025

Could we know a bit more about the use-case?
This would confirm that what you were trying to do is not already supported in a different way, or that maybe it needs some dedicated API.
Thanks!

@ndreys
Copy link
Author

ndreys commented Nov 15, 2025

Could we know a bit more about the use-case? This would confirm that what you were trying to do is not already supported in a different way, or that maybe it needs some dedicated API. Thanks!

I'm setting up device serial to contain the contents of a user (read "at manufacturing time") programmable flash. We don't know if that data is valid at compile time, so that's a string that is a result of a function call. Basically I'm doing

    static struct usbd_desc_node sn = {
        .str = {
            .utype = USBD_DUT_STRING_SERIAL_NUMBER,
            .ascii7 = true,
        },
        .bLength = USB_STRING_DESCRIPTOR_LENGTH(...),
        .bDescriptorType = USB_DESC_STRING,
    };

    sn.ptr = unit_serial_get();

older versions of USBD_DESC_STRING_DEFINE() didn't have ascii_##d_name as const, so I was originally just filling that, but it got constified recently, so I can't use that macro anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: USB Universal Serial Bus size: XS A PR changing only a single line of code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants