mirror of git://git.sysmocom.de/ofono
sim: Don't use sprintf unnecessarily
Using sprintf for a single quote is quite wasteful
This commit is contained in:
parent
95e7982938
commit
31e1b2e6ce
|
@ -305,7 +305,7 @@ static void at_sim_update_file(struct ofono_sim *sim, int cmd, int fileid,
|
||||||
struct sim_data *sd = ofono_sim_get_data(sim);
|
struct sim_data *sd = ofono_sim_get_data(sim);
|
||||||
struct cb_data *cbd = cb_data_new(cb, data);
|
struct cb_data *cbd = cb_data_new(cb, data);
|
||||||
char *buf;
|
char *buf;
|
||||||
char *quote = "";
|
gboolean quote = FALSE;
|
||||||
int len, ret;
|
int len, ret;
|
||||||
int size = 36 + p3 * 2;
|
int size = 36 + p3 * 2;
|
||||||
|
|
||||||
|
@ -317,7 +317,7 @@ static void at_sim_update_file(struct ofono_sim *sim, int cmd, int fileid,
|
||||||
case OFONO_VENDOR_ZTE:
|
case OFONO_VENDOR_ZTE:
|
||||||
case OFONO_VENDOR_HUAWEI:
|
case OFONO_VENDOR_HUAWEI:
|
||||||
case OFONO_VENDOR_SPEEDUP:
|
case OFONO_VENDOR_SPEEDUP:
|
||||||
quote = "\"";
|
quote = TRUE;
|
||||||
size += 2;
|
size += 2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -326,13 +326,16 @@ static void at_sim_update_file(struct ofono_sim *sim, int cmd, int fileid,
|
||||||
if (buf == NULL)
|
if (buf == NULL)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
len = sprintf(buf, "AT+CRSM=%i,%i,%i,%i,%i,%s", cmd, fileid,
|
len = sprintf(buf, "AT+CRSM=%i,%i,%i,%i,%i,", cmd, fileid,p1, p2, p3);
|
||||||
p1, p2, p3, quote);
|
|
||||||
|
if (quote)
|
||||||
|
buf[len++] = '\"';
|
||||||
|
|
||||||
for (; p3; p3--)
|
for (; p3; p3--)
|
||||||
len += sprintf(buf + len, "%02hhX", *value++);
|
len += sprintf(buf + len, "%02hhX", *value++);
|
||||||
|
|
||||||
sprintf(buf + len, "%s", quote);
|
if (quote)
|
||||||
|
buf[len++] = '\"';
|
||||||
|
|
||||||
ret = g_at_chat_send(sd->chat, buf, crsm_prefix,
|
ret = g_at_chat_send(sd->chat, buf, crsm_prefix,
|
||||||
at_crsm_update_cb, cbd, g_free);
|
at_crsm_update_cb, cbd, g_free);
|
||||||
|
|
Loading…
Reference in New Issue