forked from cory/tildefriends
core: Avoid trivial snprintfs.
This commit is contained in:
18
src/ssb.c
18
src/ssb.c
@ -668,7 +668,7 @@ void tf_ssb_connection_schedule_idle(tf_ssb_connection_t* connection, const char
|
||||
.callback = callback,
|
||||
.user_data = user_data,
|
||||
};
|
||||
snprintf(connection->scheduled[index].key, sizeof(connection->scheduled[index].key), "%s", key);
|
||||
tf_string_set(connection->scheduled[index].key, sizeof(connection->scheduled[index].key), key);
|
||||
connection->scheduled_count++;
|
||||
|
||||
uv_async_send(&connection->scheduled_async);
|
||||
@ -789,7 +789,7 @@ void tf_ssb_connection_add_request(tf_ssb_connection_t* connection, int32_t requ
|
||||
.dependent_connection = dependent_connection,
|
||||
.last_active = now_ms,
|
||||
};
|
||||
snprintf(request.name, sizeof(request.name), "%s", name);
|
||||
tf_string_set(request.name, sizeof(request.name), name);
|
||||
int index = tf_util_insert_index(&request_number, connection->requests, connection->requests_count, sizeof(tf_ssb_request_t), _request_compare);
|
||||
connection->requests = tf_resize_vec(connection->requests, sizeof(tf_ssb_request_t) * (connection->requests_count + 1));
|
||||
if (connection->requests_count - index)
|
||||
@ -842,7 +842,7 @@ void tf_ssb_connection_add_new_message_request(tf_ssb_connection_t* connection,
|
||||
.request_number = request_number,
|
||||
.keys = keys,
|
||||
};
|
||||
snprintf(connection->message_requests[index].author, sizeof(connection->message_requests[index].author), "%s", author);
|
||||
tf_string_set(connection->message_requests[index].author, sizeof(connection->message_requests[index].author), author);
|
||||
connection->message_requests_count++;
|
||||
}
|
||||
|
||||
@ -1703,7 +1703,7 @@ static void _tf_ssb_name_to_string(JSContext* context, JSValue object, char* buf
|
||||
else if (JS_IsString(name))
|
||||
{
|
||||
const char* part_str = JS_ToCString(context, name);
|
||||
snprintf(buffer, size, "%s", part_str);
|
||||
tf_string_set(buffer, size, part_str);
|
||||
JS_FreeCString(context, part_str);
|
||||
}
|
||||
JS_FreeValue(context, name);
|
||||
@ -1925,7 +1925,7 @@ JSValue tf_ssb_sign_message(tf_ssb_t* ssb, const char* author, const uint8_t* pr
|
||||
if (previous_id)
|
||||
{
|
||||
have_previous = *previous_id && previous_sequence > 0;
|
||||
snprintf(actual_previous_id, sizeof(actual_previous_id), "%s", previous_id);
|
||||
tf_string_set(actual_previous_id, sizeof(actual_previous_id), previous_id);
|
||||
actual_previous_sequence = previous_sequence;
|
||||
}
|
||||
else
|
||||
@ -2965,7 +2965,7 @@ static tf_ssb_connection_t* _tf_ssb_connection_create(
|
||||
tf_ssb_connection_t* connection = _tf_ssb_connection_create_internal(ssb, "cli", s_connection_index++);
|
||||
connection->connect.data = connection;
|
||||
|
||||
snprintf(connection->host, sizeof(connection->host), "%s", host);
|
||||
tf_string_set(connection->host, sizeof(connection->host), host);
|
||||
connection->port = ntohs(addr->sin_port);
|
||||
connection->connect_callback = callback;
|
||||
connection->connect_callback_user_data = user_data;
|
||||
@ -3140,7 +3140,7 @@ void tf_ssb_connect(tf_ssb_t* ssb, const char* host, int port, const uint8_t* ke
|
||||
{
|
||||
tf_ssb_connections_store(ssb->connections_tracker, host, port, id);
|
||||
}
|
||||
snprintf(connect->host, sizeof(connect->host), "%s", host);
|
||||
tf_string_set(connect->host, sizeof(connect->host), host);
|
||||
memcpy(connect->key, key, k_id_bin_len);
|
||||
tf_ssb_ref(ssb);
|
||||
int r = uv_getaddrinfo(ssb->loop, &connect->req, _tf_on_connect_getaddrinfo, host, NULL, &(struct addrinfo) { .ai_family = AF_INET });
|
||||
@ -3189,7 +3189,7 @@ static void _tf_ssb_connect_with_invite(
|
||||
{
|
||||
tf_ssb_connections_store(ssb->connections_tracker, host, port, id);
|
||||
}
|
||||
snprintf(connect->host, sizeof(connect->host), "%s", host);
|
||||
tf_string_set(connect->host, sizeof(connect->host), host);
|
||||
memcpy(connect->key, key, k_id_bin_len);
|
||||
memcpy(connect->invite, invite, sizeof(connect->invite));
|
||||
tf_ssb_ref(ssb);
|
||||
@ -4436,7 +4436,7 @@ static void _tf_ssb_update_settings_after_work(tf_ssb_t* ssb, int result, void*
|
||||
uv_timer_start(&ssb->broadcast_timer, _tf_ssb_broadcast_timer, 2000, 2000);
|
||||
}
|
||||
ssb->discovery = update->discovery;
|
||||
snprintf(ssb->seeds_host, sizeof(ssb->seeds_host), "%s", update->seeds_host);
|
||||
tf_string_set(ssb->seeds_host, sizeof(ssb->seeds_host), update->seeds_host);
|
||||
_tf_ssb_start_update_settings(ssb);
|
||||
tf_free(update);
|
||||
}
|
||||
|
Reference in New Issue
Block a user