Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4bca706

Browse files
ci(pre-commit): Apply automatic fixes
1 parent d9f89b8 commit 4bca706

File tree

3 files changed

+31
-31
lines changed

3 files changed

+31
-31
lines changed

‎cores/esp32/Arduino.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@ size_t getArduinoLoopTaskStackSize(void);
231231
* If device name is set as "", it will be ignored
232232
*/
233233
#define SET_USB_MIDI_DEVICE_NAME(name) \
234-
const char* getUSBMIDIDefaultDeviceName() { \
235-
if (!name || strlen(name) == 0) { \
234+
const char *getUSBMIDIDefaultDeviceName() { \
235+
if (!name || strlen(name) == 0) { \
236236
return ESP32_USB_MIDI_DEFAULT_NAME; \
237237
} \
238238
return name; \

‎libraries/USB/src/USBMIDI.cpp‎

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
#include "esp32-hal-tinyusb.h"
88

99
// Initialize static members
10-
char* USBMIDI::midiUserDeviceName = nullptr;
10+
char *USBMIDI::midiUserDeviceName = nullptr;
1111
// Weak definition of getUSBMIDIDefaultDeviceName to provide a default name
12-
__attribute__((weak)) const char* getUSBMIDIDefaultDeviceName() {
12+
__attribute__((weak)) const char *getUSBMIDIDefaultDeviceName() {
1313
return ESP32_USB_MIDI_DEFAULT_NAME;
1414
}
1515

@@ -49,25 +49,25 @@ USBMIDI::USBMIDI() {
4949
}
5050

5151
// private function for setting a not null/empty MIDI device name limited to 32 characters
52-
void USBMIDI::setDeviceName(const char* name) {
53-
const uint8_t maxNameLength = 32; // tinyUSB Descriptor limit
54-
if (name != nullptr && strlen(name) > 0) {
55-
if (strlen(name) > maxNameLength) {
56-
log_w("USBMIDI: Device name too long, truncating to %d characters.", maxNameLength);
57-
}
58-
if (!midiUserDeviceName) {
59-
midiUserDeviceName = new char[maxNameLength + 1]; // +1 for null-terminator
60-
}
61-
if (midiUserDeviceName) {
62-
strncpy(midiUserDeviceName, name, maxNameLength);
63-
// Ensure null-termination when overflowing
64-
midiUserDeviceName[maxNameLength] = '0円';
65-
} else {
66-
log_e("USBMIDI: Failed to allocate memory for device name, using default name.");
67-
}
52+
void USBMIDI::setDeviceName(const char *name) {
53+
const uint8_t maxNameLength = 32; // tinyUSB Descriptor limit
54+
if (name != nullptr && strlen(name) > 0) {
55+
if (strlen(name) > maxNameLength) {
56+
log_w("USBMIDI: Device name too long, truncating to %d characters.", maxNameLength);
57+
}
58+
if (!midiUserDeviceName) {
59+
midiUserDeviceName = new char[maxNameLength + 1]; // +1 for null-terminator
60+
}
61+
if (midiUserDeviceName) {
62+
strncpy(midiUserDeviceName, name, maxNameLength);
63+
// Ensure null-termination when overflowing
64+
midiUserDeviceName[maxNameLength] = '0円';
6865
} else {
69-
log_w("USBMIDI: No device name provided, using default name [%s].", getUSBMIDIDefaultDeviceName());
66+
log_e("USBMIDI: Failed to allocate memory for device name, using default name.");
7067
}
68+
} else {
69+
log_w("USBMIDI: No device name provided, using default name [%s].", getUSBMIDIDefaultDeviceName());
70+
}
7171
}
7272

7373
/**
@@ -77,7 +77,7 @@ void USBMIDI::setDeviceName(const char* name) {
7777
* 3. Default name "TinyUSB MIDI"
7878
* If device name is set as "", it will be ignored
7979
*/
80-
USBMIDI::USBMIDI(const char* name) {
80+
USBMIDI::USBMIDI(const char *name) {
8181
if (!tinyusb_midi_interface_enabled) {
8282
setDeviceName(name);
8383
tinyusb_midi_interface_enabled = true;
@@ -92,17 +92,17 @@ USBMIDI::~USBMIDI() {
9292
delete[] midiUserDeviceName;
9393
midiUserDeviceName = nullptr;
9494
}
95-
}
95+
}
9696

9797
void USBMIDI::begin() {}
9898
void USBMIDI::end() {}
9999

100-
const char* USBMIDI::getCurrentDeviceName(void) {
100+
const char *USBMIDI::getCurrentDeviceName(void) {
101101
if (midiUserDeviceName) {
102102
return midiUserDeviceName;
103103
}
104104
// If no user name set, use the compile-time default name limited to 32 characters
105-
setDeviceName(getUSBMIDIDefaultDeviceName());
105+
setDeviceName(getUSBMIDIDefaultDeviceName());
106106
if (midiUserDeviceName && strlen(midiUserDeviceName)) {
107107
return midiUserDeviceName;
108108
} else {

‎libraries/USB/src/USBMIDI.h‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ typedef struct {
1919

2020
class USBMIDI {
2121
private:
22-
static char* midiUserDeviceName; // user device name
23-
static void setDeviceName(const char* name); // set user device name limited to 32 characters
22+
static char *midiUserDeviceName; // user device name
23+
static void setDeviceName(const char *name); // set user device name limited to 32 characters
2424

2525
public:
2626
/**
@@ -37,21 +37,21 @@ class USBMIDI {
3737
* 3. Default name "TinyUSB MIDI"
3838
* It has no effect if name is set as NULL or ""
3939
*/
40-
USBMIDI(const char* name);
41-
40+
USBMIDI(const char *name);
41+
4242
~USBMIDI();
4343

4444
void begin(void);
4545
void end(void);
46-
46+
4747
/**
4848
* @brief Get the current device name
4949
* @return The device name in order of precedence:
5050
* 1. Name set via constructor (if any)
5151
* 2. Name set via SET_USB_MIDI_DEVICE_NAME() macro (if defined)
5252
* 3. Default name "TinyUSB MIDI"
5353
*/
54-
static const char* getCurrentDeviceName(void);
54+
static const char *getCurrentDeviceName(void);
5555

5656
/* User-level API */
5757

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /