diff options
author | Guy Harris <gharris@sonic.net> | 2021-04-30 03:18:25 -0700 |
---|---|---|
committer | Guy Harris <gharris@sonic.net> | 2021-04-30 03:19:19 -0700 |
commit | 57a1514ac74527651ad42dca3041f3f53509317e (patch) | |
tree | a69a01eaeac3d625a5312930fa81f0a3c6b12e96 /ui | |
parent | 09147397007c5456fd5acd4794b5ba15330bdad3 (diff) | |
download | wireshark-57a1514ac74527651ad42dca3041f3f53509317e.tar.gz wireshark-57a1514ac74527651ad42dca3041f3f53509317e.tar.bz2 wireshark-57a1514ac74527651ad42dca3041f3f53509317e.zip |
Cast away the return value of g_strlcpy() and g_strlcat().
Most of the time, the return value tells us nothing useful, as we've
already decided that we're perfectly willing to live with string
truncation. Hopefully this keeps Coverity from whining that those
routines could return an error code (NARRATOR: They don't) and thus that
we're ignoring the possibility of failure (as indicated, we've already
decided that we can live with string truncation, so truncation is *NOT*
a failure).
Diffstat (limited to 'ui')
-rw-r--r-- | ui/cli/tap-iostat.c | 2 | ||||
-rw-r--r-- | ui/cli/tap-protocolinfo.c | 2 | ||||
-rw-r--r-- | ui/qt/sctp_chunk_statistics_dialog.cpp | 8 | ||||
-rw-r--r-- | ui/summary.c | 6 | ||||
-rw-r--r-- | ui/tap-sctp-analysis.c | 10 | ||||
-rw-r--r-- | ui/text_import.c | 10 | ||||
-rw-r--r-- | ui/util.c | 4 |
7 files changed, 21 insertions, 21 deletions
diff --git a/ui/cli/tap-iostat.c b/ui/cli/tap-iostat.c index 9cc9c3484e..16306169fa 100644 --- a/ui/cli/tap-iostat.c +++ b/ui/cli/tap-iostat.c @@ -1514,7 +1514,7 @@ iostat_init(const char *opt_arg, void *userdata _U_) register_io_tap(io, i, NULL); } else { filter = (gchar *)g_malloc((pos-str)+1); - g_strlcpy( filter, str, (gsize) ((pos-str)+1)); + (void) g_strlcpy( filter, str, (gsize) ((pos-str)+1)); filter = g_strstrip(filter); register_io_tap(io, i, (char *) filter); } diff --git a/ui/cli/tap-protocolinfo.c b/ui/cli/tap-protocolinfo.c index 3ce47c854c..290f657959 100644 --- a/ui/cli/tap-protocolinfo.c +++ b/ui/cli/tap-protocolinfo.c @@ -103,7 +103,7 @@ protocolinfo_init(const char *opt_arg, void *userdata _U_) rs->hf_index = hfi->id; if ((field-filter) > 1) { rs->filter = (char *)g_malloc(field-filter); - g_strlcpy(rs->filter, filter, (field-filter)); + (void) g_strlcpy(rs->filter, filter, (field-filter)); } else { rs->filter = NULL; } diff --git a/ui/qt/sctp_chunk_statistics_dialog.cpp b/ui/qt/sctp_chunk_statistics_dialog.cpp index 0b61e9b5bd..6caa180212 100644 --- a/ui/qt/sctp_chunk_statistics_dialog.cpp +++ b/ui/qt/sctp_chunk_statistics_dialog.cpp @@ -67,10 +67,10 @@ void SCTPChunkStatisticsDialog::initializeChunkMap() temp.id = i; temp.row = i; g_snprintf(buf, sizeof buf, "%d", i); - g_strlcpy(temp.name, val_to_str_const(i, chunk_type_values, "NA"), sizeof temp.name); + (void) g_strlcpy(temp.name, val_to_str_const(i, chunk_type_values, "NA"), sizeof temp.name); if (strcmp(temp.name, "NA") == 0) { temp.hide = 1; - g_strlcpy(temp.name, buf, sizeof temp.name); + (void) g_strlcpy(temp.name, buf, sizeof temp.name); } else { temp.hide = 0; } @@ -150,7 +150,7 @@ void SCTPChunkStatisticsDialog::fillTable(bool all, const sctp_assoc_info_t *sel continue; /* Get rid of the quotation marks */ QString ch = QString(token).mid(1, (int)strlen(token)-2); - g_strlcpy(id, qPrintable(ch), sizeof id); + (void) g_strlcpy(id, qPrintable(ch), sizeof id); if (!ws_strtoi32(id, NULL, &temp.id)) continue; temp.hide = 0; @@ -164,7 +164,7 @@ void SCTPChunkStatisticsDialog::fillTable(bool all, const sctp_assoc_info_t *sel temp.hide = 0; } else { QString ch2 = QString(token).mid(1, (int)strlen(token)-2); - g_strlcpy(temp.name, qPrintable(ch2), sizeof temp.name); + (void) g_strlcpy(temp.name, qPrintable(ch2), sizeof temp.name); } } } diff --git a/ui/summary.c b/ui/summary.c index 358f082746..038aee3768 100644 --- a/ui/summary.c +++ b/ui/summary.c @@ -212,9 +212,9 @@ summary_fill_in(capture_file *cf, summary_tally *st) } g_free(idb_info); - g_strlcpy(st->file_sha256, "<unknown>", HASH_STR_SIZE); - g_strlcpy(st->file_rmd160, "<unknown>", HASH_STR_SIZE); - g_strlcpy(st->file_sha1, "<unknown>", HASH_STR_SIZE); + (void) g_strlcpy(st->file_sha256, "<unknown>", HASH_STR_SIZE); + (void) g_strlcpy(st->file_rmd160, "<unknown>", HASH_STR_SIZE); + (void) g_strlcpy(st->file_sha1, "<unknown>", HASH_STR_SIZE); gcry_md_open(&hd, GCRY_MD_SHA256, 0); if (hd) { diff --git a/ui/tap-sctp-analysis.c b/ui/tap-sctp-analysis.c index 1c17bf2fb7..8f71bba1b5 100644 --- a/ui/tap-sctp-analysis.c +++ b/ui/tap-sctp-analysis.c @@ -194,7 +194,7 @@ calc_checksum(const struct _sctp_info *check_data, sctp_assoc_info_t *data) if ((float)(data->n_adler32_correct*1.0/data->n_adler32_calculated) > 0.5) { char str[] = "ADLER32"; - g_strlcpy(data->checksum_type, str, strlen(str)); + (void) g_strlcpy(data->checksum_type, str, strlen(str)); data->n_checksum_errors=(data->n_adler32_calculated-data->n_adler32_correct); ok = TRUE; } @@ -205,7 +205,7 @@ calc_checksum(const struct _sctp_info *check_data, sctp_assoc_info_t *data) if ((float)(data->n_crc32c_correct*1.0/data->n_crc32c_calculated) > 0.5) { char str[] = "CRC32C"; - g_strlcpy(data->checksum_type, str, strlen(str)); + (void) g_strlcpy(data->checksum_type, str, strlen(str)); data->n_checksum_errors=data->n_crc32c_calculated-data->n_crc32c_correct; ok = TRUE; } @@ -214,7 +214,7 @@ calc_checksum(const struct _sctp_info *check_data, sctp_assoc_info_t *data) if (!ok) { char str[] = "UNKNOWN"; - g_strlcpy(data->checksum_type, str, strlen(str)); + (void) g_strlcpy(data->checksum_type, str, strlen(str)); data->n_checksum_errors=0; } @@ -743,7 +743,7 @@ packet(void *tapdata _U_, packet_info *pinfo, epan_dissect_t *edt _U_, const voi if ((tvb_get_guint8(sctp_info->tvb[0],0)) == SCTP_INIT_CHUNK_ID) { tmp_str = val_to_str_wmem(NULL, tvb_get_guint8(sctp_info->tvb[0],0),chunk_type_values,"Reserved (%d)"); - g_strlcpy(error->chunk_info, tmp_str, 200); + (void) g_strlcpy(error->chunk_info, tmp_str, 200); wmem_free(NULL, tmp_str); } else @@ -751,7 +751,7 @@ packet(void *tapdata _U_, packet_info *pinfo, epan_dissect_t *edt _U_, const voi for (chunk_number = 0; chunk_number < sctp_info->number_of_tvbs; chunk_number++) { tmp_str = val_to_str_wmem(NULL, tvb_get_guint8(sctp_info->tvb[chunk_number],0),chunk_type_values,"Reserved (%d)"); - g_strlcat(error->chunk_info, tmp_str, 200); + (void) g_strlcat(error->chunk_info, tmp_str, 200); wmem_free(NULL, tmp_str); } } diff --git a/ui/text_import.c b/ui/text_import.c index e3b7bb139a..ab31ce9387 100644 --- a/ui/text_import.c +++ b/ui/text_import.c @@ -669,12 +669,12 @@ append_to_preamble(char *str) if (toklen != 0) { if (packet_preamble_len + toklen > PACKET_PREAMBLE_MAX_LEN) return; /* no room to add the token to the preamble */ - g_strlcpy(&packet_preamble[packet_preamble_len], str, PACKET_PREAMBLE_MAX_LEN); + (void) g_strlcpy(&packet_preamble[packet_preamble_len], str, PACKET_PREAMBLE_MAX_LEN); packet_preamble_len += (int) toklen; if (debug >= 2) { char *c; char xs[PACKET_PREAMBLE_MAX_LEN]; - g_strlcpy(xs, packet_preamble, PACKET_PREAMBLE_MAX_LEN); + (void) g_strlcpy(xs, packet_preamble, PACKET_PREAMBLE_MAX_LEN); while ((c = strchr(xs, '\r')) != NULL) *c=' '; fprintf (stderr, "[[append_to_preamble: \"%s\"]]", xs); } @@ -941,8 +941,8 @@ static void _parse_time(const guchar* start_field, const guchar* end_field, cons char *p; int i; - g_strlcpy(field, start_field, MIN(end_field - start_field + 1, PARSE_BUF)); - g_strlcpy(format, _format, PARSE_BUF); + (void) g_strlcpy(field, start_field, MIN(end_field - start_field + 1, PARSE_BUF)); + (void) g_strlcpy(format, _format, PARSE_BUF); /* * Initialize to today localtime, just in case not all fields @@ -1017,7 +1017,7 @@ void parse_time(const guchar* start_field, const guchar* end_field, const gchar* void parse_seqno(const guchar* start_field, const guchar* end_field) { char* buf = (char*) g_alloca(end_field - start_field + 1); - g_strlcpy(buf, start_field, end_field - start_field + 1); + (void) g_strlcpy(buf, start_field, end_field - start_field + 1); seqno = g_ascii_strtoull(buf, NULL, 10); } @@ -67,11 +67,11 @@ get_args_as_string(int argc, char **argv, int optindex) argstring[0] = '\0'; i = optindex; for (;;) { - g_strlcat(argstring, argv[i], len); + (void) g_strlcat(argstring, argv[i], len); i++; if (i == argc) break; - g_strlcat(argstring, " ", len); + (void) g_strlcat(argstring, " ", len); } return argstring; } |