aboutsummaryrefslogtreecommitdiffstats
path: root/extcap
diff options
context:
space:
mode:
authorJoão Valverde <j@v6e.pt>2021-12-17 20:05:19 +0000
committerJoão Valverde <j@v6e.pt>2021-12-19 20:06:13 +0000
commitfe5248717faa1c99a4d0c761fa8da63afffc5d3f (patch)
tree80dfeee421091a44c88f80b7a65edc0590e4b4e5 /extcap
parentc5a19582e4e18605e8528cd999221444f7ece318 (diff)
Replace g_snprintf() with snprintf()
Use macros from inttypes.h with format strings.
Diffstat (limited to 'extcap')
-rw-r--r--extcap/androiddump.c22
-rw-r--r--extcap/sdjournal.c6
2 files changed, 14 insertions, 14 deletions
diff --git a/extcap/androiddump.c b/extcap/androiddump.c
index 85479cf7ec..9c6175dd2b 100644
--- a/extcap/androiddump.c
+++ b/extcap/androiddump.c
@@ -658,7 +658,7 @@ static char *adb_send_and_receive(socket_handle_t sock, const char *adb_service,
return NULL;
}
- g_snprintf(buffer, (gulong)buffer_length, ADB_HEX4_FORMAT, adb_service_length);
+ snprintf(buffer, (gulong)buffer_length, ADB_HEX4_FORMAT, adb_service_length);
result = send(sock, buffer, ADB_HEX4_LEN, 0);
if (result < ADB_HEX4_LEN) {
ws_warning("Error while sending <%s> length to ADB daemon", adb_service);
@@ -746,7 +746,7 @@ static char *adb_send_and_read(socket_handle_t sock, const char *adb_service, ch
size_t adb_service_length;
adb_service_length = strlen(adb_service);
- g_snprintf(buffer, buffer_length, ADB_HEX4_FORMAT, adb_service_length);
+ snprintf(buffer, buffer_length, ADB_HEX4_FORMAT, adb_service_length);
result = send(sock, buffer, ADB_HEX4_LEN, 0);
if (result < ADB_HEX4_LEN) {
@@ -812,7 +812,7 @@ static int adb_send(socket_handle_t sock, const char *adb_service) {
size_t adb_service_length;
adb_service_length = strlen(adb_service);
- g_snprintf(buffer, sizeof(buffer), ADB_HEX4_FORMAT, adb_service_length);
+ snprintf(buffer, sizeof(buffer), ADB_HEX4_FORMAT, adb_service_length);
result = send(sock, buffer, ADB_HEX4_LEN, 0);
if (result < ADB_HEX4_LEN) {
@@ -869,7 +869,7 @@ adb_connect_transport(const char *server_ip, unsigned short *server_tcp_port,
if (!serial_number) {
transport = adb_transport_any;
} else {
- result = g_snprintf(transport_buf, sizeof(transport_buf), adb_transport_serial_templace, serial_number);
+ result = snprintf(transport_buf, sizeof(transport_buf), adb_transport_serial_templace, serial_number);
if (result <= 0 || result > (int)sizeof(transport_buf)) {
ws_warning("Error while completing adb packet for transport");
closesocket(sock);
@@ -969,7 +969,7 @@ static int add_tcpdump_interfaces(extcap_parameters * extcap_conf, const char *a
gchar *flags = g_match_info_fetch_named(match, "flags");
if (!flags_supported || (flags && strstr(flags, "Up"))) {
- g_snprintf(iface_name, sizeof(iface_name), INTERFACE_ANDROID_TCPDUMP_FORMAT, iface);
+ snprintf(iface_name, sizeof(iface_name), INTERFACE_ANDROID_TCPDUMP_FORMAT, iface);
new_interface(extcap_conf, iface_name, iface, serial_number, "Android tcpdump");
}
g_free(flags);
@@ -1150,7 +1150,7 @@ static int register_interfaces(extcap_parameters * extcap_conf, const char *adb_
if (data_str && sscanf(data_str, "%*s %15s", pid) == 1) {
ws_debug("Android Bluetooth application PID for %s is %s", serial_number, pid);
- result = g_snprintf(check_port_buf, sizeof(check_port_buf), adb_check_port_templace, pid);
+ result = snprintf(check_port_buf, sizeof(check_port_buf), adb_check_port_templace, pid);
if (result <= 0 || result > (int)sizeof(check_port_buf)) {
ws_warning("Error while completing adb packet");
return EXIT_CODE_BAD_SIZE_OF_ASSEMBLED_ADB_PACKET_6;
@@ -1225,7 +1225,7 @@ static int register_interfaces(extcap_parameters * extcap_conf, const char *adb_
if (data_str && sscanf(data_str, "%*s %15s", pid) == 1) {
ws_debug("Android Bluetooth application PID for %s is %s", serial_number, pid);
- result = g_snprintf(check_port_buf, sizeof(check_port_buf), adb_check_port_templace, pid);
+ result = snprintf(check_port_buf, sizeof(check_port_buf), adb_check_port_templace, pid);
if (result <= 0 || result > (int)sizeof(check_port_buf)) {
ws_warning("Error while completing adb packet");
return EXIT_CODE_BAD_SIZE_OF_ASSEMBLED_ADB_PACKET_9;
@@ -1648,7 +1648,7 @@ static int adb_forward(char *serial_number, const char *adb_server_ip, unsigned
if (sock == INVALID_SOCKET)
return EXIT_CODE_INVALID_SOCKET_5;
- result = g_snprintf(helpful_packet, PACKET_LENGTH, adb_forward_template, (serial_number) ? "host-serial:" : "host", (serial_number) ? serial_number: "", local_tcp_port, server_tcp_port);
+ result = snprintf(helpful_packet, PACKET_LENGTH, adb_forward_template, (serial_number) ? "host-serial:" : "host", (serial_number) ? serial_number: "", local_tcp_port, server_tcp_port);
if (result <= 0 || result > PACKET_LENGTH) {
ws_warning("Error while completing adb packet");
closesocket(sock);
@@ -1740,7 +1740,7 @@ static int capture_android_bluetooth_external_parser(char *interface,
if (sock == INVALID_SOCKET)
return EXIT_CODE_INVALID_SOCKET_6;
- result = g_snprintf((char *) buffer, PACKET_LENGTH, adb_tcp_bluedroid_external_parser_template, *bt_server_tcp_port);
+ result = snprintf((char *) buffer, PACKET_LENGTH, adb_tcp_bluedroid_external_parser_template, *bt_server_tcp_port);
if (result <= 0 || result > PACKET_LENGTH) {
ws_warning("Error while completing adb packet");
closesocket(sock);
@@ -2061,7 +2061,7 @@ static int capture_android_logcat_text(char *interface, char *fifo,
if (!logcat_custom_parameter)
logcat_custom_parameter = "";
- result = g_snprintf((char *) packet, PACKET_LENGTH, adb_logcat_template, logcat_buffer, logcat_log_buffer, logcat_custom_parameter);
+ result = snprintf((char *) packet, PACKET_LENGTH, adb_logcat_template, logcat_buffer, logcat_log_buffer, logcat_custom_parameter);
if (result <= 0 || result > PACKET_LENGTH) {
ws_warning("Error while completing adb packet");
closesocket(sock);
@@ -2358,7 +2358,7 @@ static int capture_android_tcpdump(char *interface, char *fifo,
return EXIT_CODE_INVALID_SOCKET_11;
}
- g_snprintf(tcpdump_cmd, sizeof(tcpdump_cmd), adb_shell_tcpdump_format, iface);
+ snprintf(tcpdump_cmd, sizeof(tcpdump_cmd), adb_shell_tcpdump_format, iface);
g_free(iface);
result = adb_send(sock, tcpdump_cmd);
if (result) {
diff --git a/extcap/sdjournal.c b/extcap/sdjournal.c
index 90a330c64c..f5ad03d723 100644
--- a/extcap/sdjournal.c
+++ b/extcap/sdjournal.c
@@ -105,7 +105,7 @@ static int sdj_dump_entries(sd_journal *jnl, FILE* fp)
ws_warning("Error fetching cursor: %s", g_strerror(jr));
goto end;
}
- data_end += g_snprintf(entry_buff+data_end, MAX_EXPORT_ENTRY_LENGTH-data_end, "__CURSOR=%s\n", cursor);
+ data_end += snprintf(entry_buff+data_end, MAX_EXPORT_ENTRY_LENGTH-data_end, "__CURSOR=%s\n", cursor);
free(cursor);
jr = sd_journal_get_realtime_usec(jnl, &pkt_rt_ts);
@@ -113,7 +113,7 @@ static int sdj_dump_entries(sd_journal *jnl, FILE* fp)
ws_warning("Error fetching realtime timestamp: %s", g_strerror(jr));
goto end;
}
- data_end += g_snprintf(entry_buff+data_end, MAX_EXPORT_ENTRY_LENGTH-data_end, "__REALTIME_TIMESTAMP=%" G_GUINT64_FORMAT "\n", pkt_rt_ts);
+ data_end += snprintf(entry_buff+data_end, MAX_EXPORT_ENTRY_LENGTH-data_end, "__REALTIME_TIMESTAMP=%" PRIu64 "\n", pkt_rt_ts);
jr = sd_journal_get_monotonic_usec(jnl, &mono_ts, &boot_id);
if (jr < 0) {
@@ -121,7 +121,7 @@ static int sdj_dump_entries(sd_journal *jnl, FILE* fp)
goto end;
}
sd_id128_to_string(boot_id, boot_id_str + strlen(FLD_BOOT_ID));
- data_end += g_snprintf(entry_buff+data_end, MAX_EXPORT_ENTRY_LENGTH-data_end, "__MONOTONIC_TIMESTAMP=%" G_GUINT64_FORMAT "\n%s\n", mono_ts, boot_id_str);
+ data_end += snprintf(entry_buff+data_end, MAX_EXPORT_ENTRY_LENGTH-data_end, "__MONOTONIC_TIMESTAMP=%" PRIu64 "\n%s\n", mono_ts, boot_id_str);
ws_debug("Entry header is %u bytes", data_end);
SD_JOURNAL_FOREACH_DATA(jnl, fld_data, fld_len) {