mirror of
https://gitlab.com/mobian1/eg25-manager.git
synced 2025-08-30 07:42:23 +02:00
at_send_command: improve logging when snprintf(3) fails
This commit is contained in:
10
src/at.c
10
src/at.c
@@ -68,8 +68,14 @@ gboolean at_send_command(struct EG25Manager *manager)
|
|||||||
else if (at_cmd->subcmd && at_cmd->value)
|
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);
|
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)) {
|
if (len < 0) {
|
||||||
g_warning("AT command does not fit into buffer\n");
|
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);
|
at_next_command(manager);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user