Skip to content

Commit 58a9972

Browse files
committed
fix(idf): Fix compilation warnings when as component
1 parent 74ca7a1 commit 58a9972

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

Diff for: cores/esp32/MacAddress.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ bool MacAddress::fromString(const char *buf) {
6767

6868
//Parse user entered string into MAC address
6969
bool MacAddress::fromString6(const char *buf) {
70-
char cs[18];
70+
char cs[18]; // 17 + 1 for null terminator
7171
char *token;
7272
char *next; //Unused but required
7373
int i;
7474

75-
strncpy(cs, buf, sizeof(cs)); //strtok modifies the buffer: copy to working buffer.
75+
strncpy(cs, buf, sizeof(cs) - 1); //strtok modifies the buffer: copy to working buffer.
7676

7777
for (i = 0; i < 6; i++) {
7878
token = strtok((i == 0) ? cs : NULL, ":"); //Find first or next token
@@ -86,12 +86,12 @@ bool MacAddress::fromString6(const char *buf) {
8686
}
8787

8888
bool MacAddress::fromString8(const char *buf) {
89-
char cs[24];
89+
char cs[24]; // 23 + 1 for null terminator
9090
char *token;
9191
char *next; //Unused but required
9292
int i;
9393

94-
strncpy(cs, buf, sizeof(cs)); //strtok modifies the buffer: copy to working buffer.
94+
strncpy(cs, buf, sizeof(cs) - 1); //strtok modifies the buffer: copy to working buffer.
9595

9696
for (i = 0; i < 8; i++) {
9797
token = strtok((i == 0) ? cs : NULL, ":"); //Find first or next token

Diff for: cores/esp32/esp32-hal-adc.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ esp_err_t __analogContinuousInit(adc_channel_t *channel, uint8_t channel_num, ad
458458

459459
bool analogContinuous(uint8_t pins[], size_t pins_count, uint32_t conversions_per_pin, uint32_t sampling_freq_hz, void (*userFunc)(void)) {
460460
adc_channel_t channel[pins_count];
461-
adc_unit_t adc_unit;
461+
adc_unit_t adc_unit = ADC_UNIT_1;
462462
esp_err_t err = ESP_OK;
463463

464464
//Convert pins to channels and check if all are ADC1s unit

Diff for: libraries/Ethernet/src/ETH.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -358,11 +358,11 @@ bool ETHClass::begin(eth_phy_type_t type, int32_t phy_addr, int mdc, int mdio, i
358358
#endif /* CONFIG_ETH_USE_ESP32_EMAC */
359359

360360
#if ETH_SPI_SUPPORTS_CUSTOM
361-
static void *_eth_spi_init(const void *ctx) {
361+
__unused static void *_eth_spi_init(const void *ctx) {
362362
return (void *)ctx;
363363
}
364364

365-
static esp_err_t _eth_spi_deinit(void *ctx) {
365+
__unused static esp_err_t _eth_spi_deinit(void *ctx) {
366366
return ESP_OK;
367367
}
368368

@@ -575,8 +575,8 @@ bool ETHClass::beginSPI(
575575
}
576576

577577
// Init common MAC and PHY configs to default
578-
eth_mac_config_t eth_mac_config = ETH_MAC_DEFAULT_CONFIG();
579-
eth_phy_config_t phy_config = ETH_PHY_DEFAULT_CONFIG();
578+
__unused eth_mac_config_t eth_mac_config = ETH_MAC_DEFAULT_CONFIG();
579+
__unused eth_phy_config_t phy_config = ETH_PHY_DEFAULT_CONFIG();
580580

581581
// Update PHY config based on board specific configuration
582582
phy_config.phy_addr = phy_addr;

0 commit comments

Comments
 (0)