Feature/stm32 integration#69
Conversation
🦙 MegaLinter status: ❌ ERROR
See detailed report in MegaLinter reports |
| uint8_t ch; | ||
|
|
||
| /* Prepare AT command */ | ||
| snprintf(cmd, sizeof(cmd), "AT+SYSMFG=2,\"%s\",\"%s.0\",7,%lu", name, (unsigned long)len); |
Check warning
Code scanning / CodeQL
Too few arguments to formatting function Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 2 months ago
In general, this type of problem is fixed by making the number and types of arguments passed to the formatting function match the format string’s conversion specifiers. Either you adjust the format string to match the arguments, or you add/remove arguments to match the format string as intended.
Here, the format string includes two %s placeholders and one %lu placeholder. The arguments being passed are name and (unsigned long)len. Given the function signature int ESP_UploadChunk(const char *name, const uint8_t *data, uint32_t len), it is reasonable to infer that the second %s is meant to represent some string related to the upload, likely the name again or perhaps something derived like a version or extension, but we have no other variable available in the snippet. The least invasive, clearly correct fix (without changing documented behavior) is to supply a third argument that matches the second %s placeholder. Since we cannot invent new state or change function semantics, the safest is to use name for both %s placeholders, i.e., change the call to:
snprintf(cmd, sizeof(cmd), "AT+SYSMFG=2,\"%s\",\"%s.0\",7,%lu", name, name, (unsigned long)len);This preserves the existing format structure, satisfies the format specifiers, and does not require any new imports or definitions. The only line to change is line 250 in stm32/spotflow/network/esp_at.c.
| @@ -247,7 +247,7 @@ | ||
| uint8_t ch; | ||
|
|
||
| /* Prepare AT command */ | ||
| snprintf(cmd, sizeof(cmd), "AT+SYSMFG=2,\"%s\",\"%s.0\",7,%lu", name, (unsigned long)len); | ||
| snprintf(cmd, sizeof(cmd), "AT+SYSMFG=2,\"%s\",\"%s.0\",7,%lu", name, name, (unsigned long)len); | ||
|
|
||
| /* Send AT command */ | ||
| esp_send_raw(cmd); |

Adding Readme.