Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit02bbc3c

Browse files
committed
parse_manifest: Use const char *
This adapts the manifest parsing code to take advantage of theconst-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 parent15cd9a3 commit02bbc3c

File tree

6 files changed

+24
-24
lines changed

6 files changed

+24
-24
lines changed

‎src/backend/backup/basebackup_incremental.c

Lines 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
staticvoidmanifest_process_system_identifier(JsonManifestParseContext*context,
133133
uint64manifest_system_identifier);
134134
staticvoidmanifest_process_file(JsonManifestParseContext*context,
135-
char*pathname,
135+
constchar*pathname,
136136
size_tsize,
137137
pg_checksum_typechecksum_type,
138138
intchecksum_length,
@@ -1043,7 +1043,7 @@ manifest_process_system_identifier(JsonManifestParseContext *context,
10431043
*/
10441044
staticvoid
10451045
manifest_process_file(JsonManifestParseContext*context,
1046-
char*pathname,size_tsize,
1046+
constchar*pathname,size_tsize,
10471047
pg_checksum_typechecksum_type,
10481048
intchecksum_length,
10491049
uint8*checksum_payload)

‎src/bin/pg_combinebackup/load_manifest.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
*/
4747
#defineSH_PREFIXmanifest_files
4848
#defineSH_ELEMENT_TYPEmanifest_file
49-
#defineSH_KEY_TYPEchar *
49+
#defineSH_KEY_TYPEconstchar *
5050
#defineSH_KEYpathname
5151
#defineSH_HASH_KEY(tb,key)hash_string(key)
5252
#defineSH_EQUAL(tb,a,b)(strcmp(a, b) == 0)
@@ -60,7 +60,7 @@ static void combinebackup_version_cb(JsonManifestParseContext *context,
6060
staticvoidcombinebackup_system_identifier_cb(JsonManifestParseContext*context,
6161
uint64manifest_system_identifier);
6262
staticvoidcombinebackup_per_file_cb(JsonManifestParseContext*context,
63-
char*pathname,size_tsize,
63+
constchar*pathname,size_tsize,
6464
pg_checksum_typechecksum_type,
6565
intchecksum_length,
6666
uint8*checksum_payload);
@@ -267,7 +267,7 @@ combinebackup_system_identifier_cb(JsonManifestParseContext *context,
267267
*/
268268
staticvoid
269269
combinebackup_per_file_cb(JsonManifestParseContext*context,
270-
char*pathname,size_tsize,
270+
constchar*pathname,size_tsize,
271271
pg_checksum_typechecksum_type,
272272
intchecksum_length,uint8*checksum_payload)
273273
{

‎src/bin/pg_combinebackup/load_manifest.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
typedefstructmanifest_file
2323
{
2424
uint32status;/* hash status */
25-
char*pathname;
25+
constchar*pathname;
2626
size_tsize;
2727
pg_checksum_typechecksum_type;
2828
intchecksum_length;
@@ -31,7 +31,7 @@ typedef struct manifest_file
3131

3232
#defineSH_PREFIXmanifest_files
3333
#defineSH_ELEMENT_TYPEmanifest_file
34-
#defineSH_KEY_TYPEchar *
34+
#defineSH_KEY_TYPEconstchar *
3535
#defineSH_SCOPEextern
3636
#defineSH_RAW_ALLOCATORpg_malloc0
3737
#defineSH_DECLARE

‎src/bin/pg_verifybackup/pg_verifybackup.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
typedefstructmanifest_file
5353
{
5454
uint32status;/* hash status */
55-
char*pathname;
55+
constchar*pathname;
5656
size_tsize;
5757
pg_checksum_typechecksum_type;
5858
intchecksum_length;
@@ -70,7 +70,7 @@ typedef struct manifest_file
7070
*/
7171
#defineSH_PREFIXmanifest_files
7272
#defineSH_ELEMENT_TYPEmanifest_file
73-
#defineSH_KEY_TYPEchar *
73+
#defineSH_KEY_TYPEconstchar *
7474
#defineSH_KEYpathname
7575
#defineSH_HASH_KEY(tb,key)hash_string(key)
7676
#defineSH_EQUAL(tb,a,b)(strcmp(a, b) == 0)
@@ -123,7 +123,7 @@ static void verifybackup_version_cb(JsonManifestParseContext *context,
123123
staticvoidverifybackup_system_identifier(JsonManifestParseContext*context,
124124
uint64manifest_system_identifier);
125125
staticvoidverifybackup_per_file_cb(JsonManifestParseContext*context,
126-
char*pathname,size_tsize,
126+
constchar*pathname,size_tsize,
127127
pg_checksum_typechecksum_type,
128128
intchecksum_length,
129129
uint8*checksum_payload);
@@ -155,7 +155,7 @@ static void report_backup_error(verifier_context *context,
155155
pg_attribute_printf(2,3);
156156
staticvoidreport_fatal_error(constchar*pg_restrictfmt,...)
157157
pg_attribute_printf(1,2)pg_attribute_noreturn();
158-
staticboolshould_ignore_relpath(verifier_context*context,char*relpath);
158+
staticboolshould_ignore_relpath(verifier_context*context,constchar*relpath);
159159

160160
staticvoidprogress_report(boolfinished);
161161
staticvoidusage(void);
@@ -546,7 +546,7 @@ verifybackup_system_identifier(JsonManifestParseContext *context,
546546
*/
547547
staticvoid
548548
verifybackup_per_file_cb(JsonManifestParseContext*context,
549-
char*pathname,size_tsize,
549+
constchar*pathname,size_tsize,
550550
pg_checksum_typechecksum_type,
551551
intchecksum_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_contextchecksum_ctx;
855-
char*relpath=m->pathname;
855+
constchar*relpath=m->pathname;
856856
intfd;
857857
intrc;
858858
size_tbytes_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
staticbool
1019-
should_ignore_relpath(verifier_context*context,char*relpath)
1019+
should_ignore_relpath(verifier_context*context,constchar*relpath)
10201020
{
10211021
SimpleStringListCell*cell;
10221022

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

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

‎src/common/parse_manifest.c

Lines 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
staticvoidjson_manifest_finalize_file(JsonManifestParseState*parse);
113113
staticvoidjson_manifest_finalize_wal_range(JsonManifestParseState*parse);
114114
staticvoidverify_manifest_checksum(JsonManifestParseState*parse,
115-
char*buffer,size_tsize,
115+
constchar*buffer,size_tsize,
116116
pg_cryptohash_ctx*incr_ctx);
117117
staticvoidjson_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_tsize,
186+
JsonManifestParseIncrementalState*incstate,constchar*chunk,size_tsize,
187187
boolis_last)
188188
{
189189
JsonParseErrorTyperes,
@@ -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+
(constuint8*)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,constchar*buffer,
229229
size_tsize)
230230
{
231231
JsonLexContext*lex;
@@ -810,7 +810,7 @@ json_manifest_finalize_wal_range(JsonManifestParseState *parse)
810810
* parse incr_ctx will be NULL.
811811
*/
812812
staticvoid
813-
verify_manifest_checksum(JsonManifestParseState*parse,char*buffer,
813+
verify_manifest_checksum(JsonManifestParseState*parse,constchar*buffer,
814814
size_tsize,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, (constuint8*)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

Lines 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
typedefvoid (*json_manifest_system_identifier_callback) (JsonManifestParseContext*,
2828
uint64manifest_system_identifier);
2929
typedefvoid (*json_manifest_per_file_callback) (JsonManifestParseContext*,
30-
char*pathname,
30+
constchar*pathname,
3131
size_tsize,pg_checksum_typechecksum_type,
3232
intchecksum_length,uint8*checksum_payload);
3333
typedefvoid (*json_manifest_per_wal_range_callback) (JsonManifestParseContext*,
@@ -48,10 +48,10 @@ struct JsonManifestParseContext
4848
};
4949

5050
externvoidjson_parse_manifest(JsonManifestParseContext*context,
51-
char*buffer,size_tsize);
51+
constchar*buffer,size_tsize);
5252
externJsonManifestParseIncrementalState*json_parse_manifest_incremental_init(JsonManifestParseContext*context);
5353
externvoidjson_parse_manifest_incremental_chunk(
54-
JsonManifestParseIncrementalState*incstate,char*chunk,size_tsize,
54+
JsonManifestParseIncrementalState*incstate,constchar*chunk,size_tsize,
5555
boolis_last);
5656
externvoidjson_parse_manifest_incremental_shutdown(JsonManifestParseIncrementalState*incstate);
5757

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp