Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 02bbc3c

Browse filesBrowse files
committed
parse_manifest: Use const char *
This adapts the manifest parsing code to take advantage of the const-ified jsonapi. Reviewed-by: Andrew Dunstan <andrew@dunslane.net> Discussion: https://www.postgresql.org/message-id/flat/f732b014-f614-4600-a437-dba5a2c3738b%40eisentraut.org
1 parent 15cd9a3 commit 02bbc3c
Copy full SHA for 02bbc3c

File tree

Expand file treeCollapse file tree

6 files changed

+24
-24
lines changed
Filter options
Expand file treeCollapse file tree

6 files changed

+24
-24
lines changed

‎src/backend/backup/basebackup_incremental.c

Copy file name to clipboardExpand all lines: src/backend/backup/basebackup_incremental.c
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ static void manifest_process_version(JsonManifestParseContext *context,
132132
static void manifest_process_system_identifier(JsonManifestParseContext *context,
133133
uint64 manifest_system_identifier);
134134
static void manifest_process_file(JsonManifestParseContext *context,
135-
char *pathname,
135+
const char *pathname,
136136
size_t size,
137137
pg_checksum_type checksum_type,
138138
int checksum_length,
@@ -1043,7 +1043,7 @@ manifest_process_system_identifier(JsonManifestParseContext *context,
10431043
*/
10441044
static void
10451045
manifest_process_file(JsonManifestParseContext *context,
1046-
char *pathname, size_t size,
1046+
const char *pathname, size_t size,
10471047
pg_checksum_type checksum_type,
10481048
int checksum_length,
10491049
uint8 *checksum_payload)

‎src/bin/pg_combinebackup/load_manifest.c

Copy file name to clipboardExpand all lines: src/bin/pg_combinebackup/load_manifest.c
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
*/
4747
#define SH_PREFIX manifest_files
4848
#define SH_ELEMENT_TYPE manifest_file
49-
#define SH_KEY_TYPE char *
49+
#define SH_KEY_TYPE const char *
5050
#define SH_KEY pathname
5151
#define SH_HASH_KEY(tb, key) hash_string(key)
5252
#define SH_EQUAL(tb, a, b) (strcmp(a, b) == 0)
@@ -60,7 +60,7 @@ static void combinebackup_version_cb(JsonManifestParseContext *context,
6060
static void combinebackup_system_identifier_cb(JsonManifestParseContext *context,
6161
uint64 manifest_system_identifier);
6262
static void combinebackup_per_file_cb(JsonManifestParseContext *context,
63-
char *pathname, size_t size,
63+
const char *pathname, size_t size,
6464
pg_checksum_type checksum_type,
6565
int checksum_length,
6666
uint8 *checksum_payload);
@@ -267,7 +267,7 @@ combinebackup_system_identifier_cb(JsonManifestParseContext *context,
267267
*/
268268
static void
269269
combinebackup_per_file_cb(JsonManifestParseContext *context,
270-
char *pathname, size_t size,
270+
const char *pathname, size_t size,
271271
pg_checksum_type checksum_type,
272272
int checksum_length, uint8 *checksum_payload)
273273
{

‎src/bin/pg_combinebackup/load_manifest.h

Copy file name to clipboardExpand all lines: src/bin/pg_combinebackup/load_manifest.h
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
typedef struct manifest_file
2323
{
2424
uint32 status; /* hash status */
25-
char *pathname;
25+
const char *pathname;
2626
size_t size;
2727
pg_checksum_type checksum_type;
2828
int checksum_length;
@@ -31,7 +31,7 @@ typedef struct manifest_file
3131

3232
#define SH_PREFIX manifest_files
3333
#define SH_ELEMENT_TYPE manifest_file
34-
#define SH_KEY_TYPE char *
34+
#define SH_KEY_TYPE const char *
3535
#define SH_SCOPE extern
3636
#define SH_RAW_ALLOCATOR pg_malloc0
3737
#define SH_DECLARE

‎src/bin/pg_verifybackup/pg_verifybackup.c

Copy file name to clipboardExpand all lines: src/bin/pg_verifybackup/pg_verifybackup.c
+8-8Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
typedef struct manifest_file
5353
{
5454
uint32 status; /* hash status */
55-
char *pathname;
55+
const char *pathname;
5656
size_t size;
5757
pg_checksum_type checksum_type;
5858
int checksum_length;
@@ -70,7 +70,7 @@ typedef struct manifest_file
7070
*/
7171
#define SH_PREFIX manifest_files
7272
#define SH_ELEMENT_TYPE manifest_file
73-
#define SH_KEY_TYPE char *
73+
#define SH_KEY_TYPE const char *
7474
#define SH_KEY pathname
7575
#define SH_HASH_KEY(tb, key) hash_string(key)
7676
#define SH_EQUAL(tb, a, b) (strcmp(a, b) == 0)
@@ -123,7 +123,7 @@ static void verifybackup_version_cb(JsonManifestParseContext *context,
123123
static void verifybackup_system_identifier(JsonManifestParseContext *context,
124124
uint64 manifest_system_identifier);
125125
static void verifybackup_per_file_cb(JsonManifestParseContext *context,
126-
char *pathname, size_t size,
126+
const char *pathname, size_t size,
127127
pg_checksum_type checksum_type,
128128
int checksum_length,
129129
uint8 *checksum_payload);
@@ -155,7 +155,7 @@ static void report_backup_error(verifier_context *context,
155155
pg_attribute_printf(2, 3);
156156
static void report_fatal_error(const char *pg_restrict fmt,...)
157157
pg_attribute_printf(1, 2) pg_attribute_noreturn();
158-
static bool should_ignore_relpath(verifier_context *context, char *relpath);
158+
static bool should_ignore_relpath(verifier_context *context, const char *relpath);
159159

160160
static void progress_report(bool finished);
161161
static void usage(void);
@@ -546,7 +546,7 @@ verifybackup_system_identifier(JsonManifestParseContext *context,
546546
*/
547547
static void
548548
verifybackup_per_file_cb(JsonManifestParseContext *context,
549-
char *pathname, size_t size,
549+
const char *pathname, size_t size,
550550
pg_checksum_type checksum_type,
551551
int checksum_length, uint8 *checksum_payload)
552552
{
@@ -852,7 +852,7 @@ verify_file_checksum(verifier_context *context, manifest_file *m,
852852
char *fullpath, uint8 *buffer)
853853
{
854854
pg_checksum_context checksum_ctx;
855-
char *relpath = m->pathname;
855+
const char *relpath = m->pathname;
856856
int fd;
857857
int rc;
858858
size_t bytes_read = 0;
@@ -1016,13 +1016,13 @@ report_fatal_error(const char *pg_restrict fmt,...)
10161016
* "aa/bb" is not a prefix of "aa/bbb", but it is a prefix of "aa/bb/cc".
10171017
*/
10181018
static bool
1019-
should_ignore_relpath(verifier_context *context, char *relpath)
1019+
should_ignore_relpath(verifier_context *context, const char *relpath)
10201020
{
10211021
SimpleStringListCell *cell;
10221022

10231023
for (cell = context->ignore_list.head; cell != NULL; cell = cell->next)
10241024
{
1025-
char *r = relpath;
1025+
const char *r = relpath;
10261026
char *v = cell->val;
10271027

10281028
while (*v != '\0' && *r == *v)

‎src/common/parse_manifest.c

Copy file name to clipboardExpand all lines: src/common/parse_manifest.c
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ static void json_manifest_finalize_system_identifier(JsonManifestParseState *par
112112
static void json_manifest_finalize_file(JsonManifestParseState *parse);
113113
static void json_manifest_finalize_wal_range(JsonManifestParseState *parse);
114114
static void verify_manifest_checksum(JsonManifestParseState *parse,
115-
char *buffer, size_t size,
115+
const char *buffer, size_t size,
116116
pg_cryptohash_ctx *incr_ctx);
117117
static void json_manifest_parse_failure(JsonManifestParseContext *context,
118118
char *msg);
@@ -183,7 +183,7 @@ json_parse_manifest_incremental_shutdown(JsonManifestParseIncrementalState *incs
183183

184184
void
185185
json_parse_manifest_incremental_chunk(
186-
JsonManifestParseIncrementalState *incstate, char *chunk, size_t size,
186+
JsonManifestParseIncrementalState *incstate, const char *chunk, size_t size,
187187
bool is_last)
188188
{
189189
JsonParseErrorType res,
@@ -206,7 +206,7 @@ json_parse_manifest_incremental_chunk(
206206
if (!is_last)
207207
{
208208
if (pg_cryptohash_update(incstate->manifest_ctx,
209-
(uint8 *) chunk, size) < 0)
209+
(const uint8 *) chunk, size) < 0)
210210
context->error_cb(context, "could not update checksum of manifest");
211211
}
212212
else
@@ -225,7 +225,7 @@ json_parse_manifest_incremental_chunk(
225225
* invoked and is expected not to return.
226226
*/
227227
void
228-
json_parse_manifest(JsonManifestParseContext *context, char *buffer,
228+
json_parse_manifest(JsonManifestParseContext *context, const char *buffer,
229229
size_t size)
230230
{
231231
JsonLexContext *lex;
@@ -810,7 +810,7 @@ json_manifest_finalize_wal_range(JsonManifestParseState *parse)
810810
* parse incr_ctx will be NULL.
811811
*/
812812
static void
813-
verify_manifest_checksum(JsonManifestParseState *parse, char *buffer,
813+
verify_manifest_checksum(JsonManifestParseState *parse, const char *buffer,
814814
size_t size, pg_cryptohash_ctx *incr_ctx)
815815
{
816816
JsonManifestParseContext *context = parse->context;
@@ -858,7 +858,7 @@ verify_manifest_checksum(JsonManifestParseState *parse, char *buffer,
858858
{
859859
manifest_ctx = incr_ctx;
860860
}
861-
if (pg_cryptohash_update(manifest_ctx, (uint8 *) buffer, penultimate_newline + 1) < 0)
861+
if (pg_cryptohash_update(manifest_ctx, (const uint8 *) buffer, penultimate_newline + 1) < 0)
862862
context->error_cb(context, "could not update checksum of manifest");
863863
if (pg_cryptohash_final(manifest_ctx, manifest_checksum_actual,
864864
sizeof(manifest_checksum_actual)) < 0)

‎src/include/common/parse_manifest.h

Copy file name to clipboardExpand all lines: src/include/common/parse_manifest.h
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ typedef void (*json_manifest_version_callback) (JsonManifestParseContext *,
2727
typedef void (*json_manifest_system_identifier_callback) (JsonManifestParseContext *,
2828
uint64 manifest_system_identifier);
2929
typedef void (*json_manifest_per_file_callback) (JsonManifestParseContext *,
30-
char *pathname,
30+
const char *pathname,
3131
size_t size, pg_checksum_type checksum_type,
3232
int checksum_length, uint8 *checksum_payload);
3333
typedef void (*json_manifest_per_wal_range_callback) (JsonManifestParseContext *,
@@ -48,10 +48,10 @@ struct JsonManifestParseContext
4848
};
4949

5050
extern void json_parse_manifest(JsonManifestParseContext *context,
51-
char *buffer, size_t size);
51+
const char *buffer, size_t size);
5252
extern JsonManifestParseIncrementalState *json_parse_manifest_incremental_init(JsonManifestParseContext *context);
5353
extern void json_parse_manifest_incremental_chunk(
54-
JsonManifestParseIncrementalState *incstate, char *chunk, size_t size,
54+
JsonManifestParseIncrementalState *incstate, const char *chunk, size_t size,
5555
bool is_last);
5656
extern void json_parse_manifest_incremental_shutdown(JsonManifestParseIncrementalState *incstate);
5757

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.