at_send_command: improve logging when snprintf(3) fails

This commit is contained in:
Xavier Del Campo
2021-09-28 23:25:19 +02:00
parent 771e9f8316
commit 6f91389496

View File

@@ -68,8 +68,14 @@ gboolean at_send_command(struct EG25Manager *manager)
else if (at_cmd->subcmd && at_cmd->value)
len = snprintf(command, sizeof(command), "AT+%s=\"%s\",%s\r\n", at_cmd->cmd, at_cmd->subcmd, at_cmd->value);
if (len < 0 || len >= sizeof(command)) {
g_warning("AT command does not fit into buffer\n");
if (len < 0) {
g_warning("snprintf(3) failed");
at_next_command(manager);
return FALSE;
}
else if (len >= sizeof(command)) {
g_warning("AT command does not fit into buffer "
"(%d bytes required, %zu available)", len, sizeof(command));
at_next_command(manager);
return FALSE;
}