)]}'
{"/PATCHSET_LEVEL":[{"author":{"_account_id":1000021,"name":"Antonio Borneo","email":"borneo.antonio@gmail.com","username":"borneoa"},"change_message_id":"8fdbe84f0502910b990d3455d8ff99679938dc11","unresolved":true,"context_lines":[],"source_content_type":"","patch_set":2,"id":"012cc660_e4891abd","updated":"2023-12-29 15:55:19.000000000","message":"Cool, thanks!\nI think using void pointer for the allocated memory could help avoiding useless cast in the code. What\u0027s your opinion?","commit_id":"e3c4ebca378b8d1f58139fb13d660c289e716522"}],"src/jtag/drivers/libusb_helper.c":[{"author":{"_account_id":1000021,"name":"Antonio Borneo","email":"borneo.antonio@gmail.com","username":"borneoa"},"change_message_id":"8fdbe84f0502910b990d3455d8ff99679938dc11","unresolved":true,"context_lines":[{"line_number":386,"context_line":""},{"line_number":387,"context_line":"/* Older libusb does not implement following API calls - define stubs instead */"},{"line_number":388,"context_line":"#if !defined(LIBUSB_API_VERSION) || (LIBUSB_API_VERSION \u003c 0x01000105)"},{"line_number":389,"context_line":"static uint8_t *libusb_dev_mem_alloc(libusb_device_handle *devh, size_t length)"},{"line_number":390,"context_line":"{"},{"line_number":391,"context_line":"\treturn NULL;"},{"line_number":392,"context_line":"}"}],"source_content_type":"text/x-csrc","patch_set":2,"id":"c266b0b0_42496d34","line":389,"updated":"2023-12-29 15:55:19.000000000","message":"the libusb prototype is\nunsigned char * LIBUSB_CALL libusb_dev_mem_alloc(...\nShould we stick to \u0027unsigned char *\u0027 here and in the oocd_ wrapper?\nOr, even better, move oocd_ wrapper only to \u0027void *\u0027 like malloc() so we can assign the result to any pointer type? In such case, also for the argument of the oocd_ free","commit_id":"e3c4ebca378b8d1f58139fb13d660c289e716522"},{"author":{"_account_id":1000021,"name":"Antonio Borneo","email":"borneo.antonio@gmail.com","username":"borneoa"},"change_message_id":"ea963e1f9817521ce555ffdc8095658c514723f1","unresolved":false,"context_lines":[{"line_number":386,"context_line":""},{"line_number":387,"context_line":"/* Older libusb does not implement following API calls - define stubs instead */"},{"line_number":388,"context_line":"#if !defined(LIBUSB_API_VERSION) || (LIBUSB_API_VERSION \u003c 0x01000105)"},{"line_number":389,"context_line":"static uint8_t *libusb_dev_mem_alloc(libusb_device_handle *devh, size_t length)"},{"line_number":390,"context_line":"{"},{"line_number":391,"context_line":"\treturn NULL;"},{"line_number":392,"context_line":"}"}],"source_content_type":"text/x-csrc","patch_set":2,"id":"e6541391_ba74389d","line":389,"in_reply_to":"7164d3df_70b4f9e7","updated":"2023-12-29 21:02:33.000000000","message":"For these APIs to allocate, deallocate and transfer buffers, using void pointer sounds to me reasonable. Then user can choose any other host type with no need for cast.\nWe prefer stdint types when we want to match the size of a target\u0027s data type.\nFor USB buffers, either int8_t or uint8_t should be fine.\nI would tend to exclude the use of char and unsigned char; but if the buffer has to be passed to an API that requires char or unsigned char, then I prefer user allocates the buffer to such types to avoid any cast.","commit_id":"e3c4ebca378b8d1f58139fb13d660c289e716522"},{"author":{"_account_id":1000687,"name":"Tomas Vanek","display_name":"Tomas Vanek","email":"vanekt@fbl.cz","username":"vanekt"},"change_message_id":"a975dbf141546ae656c4ae0972ed2b7ff2577851","unresolved":false,"context_lines":[{"line_number":386,"context_line":""},{"line_number":387,"context_line":"/* Older libusb does not implement following API calls - define stubs instead */"},{"line_number":388,"context_line":"#if !defined(LIBUSB_API_VERSION) || (LIBUSB_API_VERSION \u003c 0x01000105)"},{"line_number":389,"context_line":"static uint8_t *libusb_dev_mem_alloc(libusb_device_handle *devh, size_t length)"},{"line_number":390,"context_line":"{"},{"line_number":391,"context_line":"\treturn NULL;"},{"line_number":392,"context_line":"}"}],"source_content_type":"text/x-csrc","patch_set":2,"id":"7164d3df_70b4f9e7","line":389,"in_reply_to":"c266b0b0_42496d34","updated":"2023-12-29 19:15:17.000000000","message":"I assume oocd_libusb_dev_mem_alloc() will be used for bulk transfers and they almost exclusively use uint8_t typed buffers. The only exception I found is xds110 with unsigned char buffer type (which could be easily changed to uint8_t).\n\nAnyway we should change jtag_libusb_bulk_write()/jtag_libusb_bulk_read() definition: it casts libusb_bulk_transfer() unsigned char buffer to (signed) char. Seems me totally silly as all callers cast the parameter back to uint8_t or unsigned char.","commit_id":"e3c4ebca378b8d1f58139fb13d660c289e716522"},{"author":{"_account_id":1000687,"name":"Tomas Vanek","display_name":"Tomas Vanek","email":"vanekt@fbl.cz","username":"vanekt"},"change_message_id":"5ce255c9c979c677ad2ef05cd053c8e29287dc64","unresolved":false,"context_lines":[{"line_number":386,"context_line":""},{"line_number":387,"context_line":"/* Older libusb does not implement following API calls - define stubs instead */"},{"line_number":388,"context_line":"#if !defined(LIBUSB_API_VERSION) || (LIBUSB_API_VERSION \u003c 0x01000105)"},{"line_number":389,"context_line":"static uint8_t *libusb_dev_mem_alloc(libusb_device_handle *devh, size_t length)"},{"line_number":390,"context_line":"{"},{"line_number":391,"context_line":"\treturn NULL;"},{"line_number":392,"context_line":"}"}],"source_content_type":"text/x-csrc","patch_set":2,"id":"29b6c08e_ee60fa0e","line":389,"in_reply_to":"e6541391_ba74389d","updated":"2024-01-04 06:26:48.000000000","message":"\u003e For these APIs to allocate, deallocate and transfer buffers, using void pointer sounds to me reasonable...\n\nlibusb_dev_mem_alloc() is not yet another malloc(), it is highly specific allocator. I strongly prefer uint8_t for oocd wrapper for the same reason the original API used unsigned char. I assume any meaningful usage will work with uint8_t typed buffer.\nIf the future shows that I was wrong, anybody can revisit the wrapper.\n\nLet\u0027s stop this fruitless discussion: CMSIS-DAP support is still broken on macOS and waiting for #8044","commit_id":"e3c4ebca378b8d1f58139fb13d660c289e716522"}]}
