8000 Use %zu for size_t values (sizeof, strlen). by dimitri · Pull Request #627 · dimitri/pgcopydb · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Use %zu for size_t values (sizeof, strlen). #627

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/bin/pgcopydb/env_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ get_env_copy_with_fallback(const char *name, char *result, int maxLength,
if (actualLength >= maxLength)
{
log_error("Failed to copy value stored in %s environment setting, "
"which is %lu long. pgcopydb only supports %lu bytes for "
"which is %zu long. pgcopydb only supports %d bytes for "
"this environment setting",
name,
(unsigned long) actualLength,
(unsigned long) maxLength - 1);
actualLength,
maxLength - 1);
return false;
}
return true;
Expand Down
5 changes: 2 additions & 3 deletions src/bin/pgcopydb/file_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -1235,9 +1235,8 @@ sformat(char *str, size_t count, const char *fmt, ...)
if (len >= count)
{
log_error("BUG: sformat needs %d bytes to expend format string \"%s\", "
"and a target string of %lu bytes only has been given.",
len, fmt,
(unsigned long) count);
"and a target string of %zu bytes only has been given.",
len, fmt, count);
}

return len;
Expand Down
4 changes: 2 additions & 2 deletions src/bin/pgcopydb/filtering.c
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ parse_filter_quoted_table_name(SourceFilterTable *table, const char *qname)
if (nspbytes >= sizeof(table->nspname))
{
log_error("Failed to parse schema name \"%s\" (%d bytes long), "
"pgcopydb and Postgres only support names up to %lu bytes",
"pgcopydb and Postgres only support names up to %zu bytes",
table->nspname,
nsplen,
sizeof(table->nspname));
Expand Down Expand Up @@ -474,7 +474,7 @@ parse_filter_quoted_table_name(SourceFilterTable *table, const char *qname)
if (relbytes >= sizeof(table->relname))
{
log_error("Failed to parse relation name \"%s\" (%d bytes long), "
"pgcopydb and Postgres only support names up to %lu bytes",
"pgcopydb and Postgres only support names up to %zu bytes",
table->relname,
rellen,
sizeof(table->relname));
Expand Down
4 changes: 2 additions & 2 deletions src/bin/pgcopydb/ld_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -1908,8 +1908,8 @@ parseMessageMetadata(LogicalMessageMetadata *metadata,
if (strlcpy(metadata->timestamp, timestamp, n) >= n)
{
log_error("Failed to parse JSON message timestamp value \"%s\" "
"which is %lu bytes long, "
"pgcopydb only support timestamps up to %lu bytes",
"which is %zu bytes long, "
"pgcopydb only support timestamps up to %zu bytes",
timestamp,
strlen(timestamp),
sizeof(metadata->timestamp));
Expand Down
8 changes: 4 additions & 4 deletions src/bin/pgcopydb/pgsql.c
Original file line number Diff line number Diff line change
Expand Up @@ -3173,10 +3173,10 @@ parseTimelineHistoryResult(void *ctx, PGresult *result)

if (strlen(value) >= sizeof(context->content))
{
log_error("Received a timeline history file of %lu bytes, "
"pgcopydb is limited to files of up to %lu bytes.",
(unsigned long) strlen(value),
(unsigned long) sizeof(context->content));
log_error("Received a timeline history file of %zu bytes, "
"pgcopydb is limited to files of up to %zu bytes.",
strlen(value),
sizeof(context->content));
context->parsedOk = false;
}
strlcpy(context->content, value, sizeof(context->content));
Expand Down
0