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 cb_data *cbd = cb_data_new(cb, data);
|
||||
char *buf;
|
||||
char *quote = "";
|
||||
gboolean quote = FALSE;
|
||||
int len, ret;
|
||||
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_HUAWEI:
|
||||
case OFONO_VENDOR_SPEEDUP:
|
||||
quote = "\"";
|
||||
quote = TRUE;
|
||||
size += 2;
|
||||
break;
|
||||
}
|
||||
|
@ -326,13 +326,16 @@ static void at_sim_update_file(struct ofono_sim *sim, int cmd, int fileid,
|
|||
if (buf == NULL)
|
||||
goto error;
|
||||
|
||||
len = sprintf(buf, "AT+CRSM=%i,%i,%i,%i,%i,%s", cmd, fileid,
|
||||
p1, p2, p3, quote);
|
||||
len = sprintf(buf, "AT+CRSM=%i,%i,%i,%i,%i,", cmd, fileid,p1, p2, p3);
|
||||
|
||||
if (quote)
|
||||
buf[len++] = '\"';
|
||||
|
||||
for (; p3; p3--)
|
||||
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,
|
||||
at_crsm_update_cb, cbd, g_free);
|
||||
|
|
Loading…
Reference in New Issue