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

Commitefcd519

Browse files
committed
Make some use of anonymous unions [pgcrypto]
Make some use of anonymous unions, which are allowed as of C11, asexamples and encouragement for future code, and to test compilers.This commit changes some structures in pgcrypto.Reviewed-by: Chao Li <li.evan.chao@gmail.com>Discussion:https://www.postgresql.org/message-id/flat/f00a9968-388e-4f8c-b5ef-5102e962d997%40eisentraut.org
1 parent57d46df commitefcd519

File tree

3 files changed

+26
-26
lines changed

3 files changed

+26
-26
lines changed

‎contrib/pgcrypto/openssl.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ free_openssl_digest(OSSLDigest *digest)
9898
staticunsigned
9999
digest_result_size(PX_MD*h)
100100
{
101-
OSSLDigest*digest= (OSSLDigest*)h->p.ptr;
101+
OSSLDigest*digest= (OSSLDigest*)h->ptr;
102102
intresult=EVP_MD_CTX_size(digest->ctx);
103103

104104
if (result<0)
@@ -110,7 +110,7 @@ digest_result_size(PX_MD *h)
110110
staticunsigned
111111
digest_block_size(PX_MD*h)
112112
{
113-
OSSLDigest*digest= (OSSLDigest*)h->p.ptr;
113+
OSSLDigest*digest= (OSSLDigest*)h->ptr;
114114
intresult=EVP_MD_CTX_block_size(digest->ctx);
115115

116116
if (result<0)
@@ -122,7 +122,7 @@ digest_block_size(PX_MD *h)
122122
staticvoid
123123
digest_reset(PX_MD*h)
124124
{
125-
OSSLDigest*digest= (OSSLDigest*)h->p.ptr;
125+
OSSLDigest*digest= (OSSLDigest*)h->ptr;
126126

127127
if (!EVP_DigestInit_ex(digest->ctx,digest->algo,NULL))
128128
elog(ERROR,"EVP_DigestInit_ex() failed");
@@ -131,7 +131,7 @@ digest_reset(PX_MD *h)
131131
staticvoid
132132
digest_update(PX_MD*h,constuint8*data,unsigneddlen)
133133
{
134-
OSSLDigest*digest= (OSSLDigest*)h->p.ptr;
134+
OSSLDigest*digest= (OSSLDigest*)h->ptr;
135135

136136
if (!EVP_DigestUpdate(digest->ctx,data,dlen))
137137
elog(ERROR,"EVP_DigestUpdate() failed");
@@ -140,7 +140,7 @@ digest_update(PX_MD *h, const uint8 *data, unsigned dlen)
140140
staticvoid
141141
digest_finish(PX_MD*h,uint8*dst)
142142
{
143-
OSSLDigest*digest= (OSSLDigest*)h->p.ptr;
143+
OSSLDigest*digest= (OSSLDigest*)h->ptr;
144144

145145
if (!EVP_DigestFinal_ex(digest->ctx,dst,NULL))
146146
elog(ERROR,"EVP_DigestFinal_ex() failed");
@@ -149,7 +149,7 @@ digest_finish(PX_MD *h, uint8 *dst)
149149
staticvoid
150150
digest_free(PX_MD*h)
151151
{
152-
OSSLDigest*digest= (OSSLDigest*)h->p.ptr;
152+
OSSLDigest*digest= (OSSLDigest*)h->ptr;
153153

154154
free_openssl_digest(digest);
155155
pfree(h);
@@ -204,7 +204,7 @@ px_find_digest(const char *name, PX_MD **res)
204204
h->update=digest_update;
205205
h->finish=digest_finish;
206206
h->free=digest_free;
207-
h->p.ptr=digest;
207+
h->ptr=digest;
208208

209209
*res=h;
210210
return0;

‎contrib/pgcrypto/px.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ struct px_digest
117117
{
118118
unsignedcode;
119119
void*ptr;
120-
}p;
120+
};
121121
};
122122

123123
structpx_alias

‎src/common/cryptohash.c‎

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -105,22 +105,22 @@ pg_cryptohash_init(pg_cryptohash_ctx *ctx)
105105
switch (ctx->type)
106106
{
107107
casePG_MD5:
108-
pg_md5_init(&ctx->data.md5);
108+
pg_md5_init(&ctx->md5);
109109
break;
110110
casePG_SHA1:
111-
pg_sha1_init(&ctx->data.sha1);
111+
pg_sha1_init(&ctx->sha1);
112112
break;
113113
casePG_SHA224:
114-
pg_sha224_init(&ctx->data.sha224);
114+
pg_sha224_init(&ctx->sha224);
115115
break;
116116
casePG_SHA256:
117-
pg_sha256_init(&ctx->data.sha256);
117+
pg_sha256_init(&ctx->sha256);
118118
break;
119119
casePG_SHA384:
120-
pg_sha384_init(&ctx->data.sha384);
120+
pg_sha384_init(&ctx->sha384);
121121
break;
122122
casePG_SHA512:
123-
pg_sha512_init(&ctx->data.sha512);
123+
pg_sha512_init(&ctx->sha512);
124124
break;
125125
}
126126

@@ -141,22 +141,22 @@ pg_cryptohash_update(pg_cryptohash_ctx *ctx, const uint8 *data, size_t len)
141141
switch (ctx->type)
142142
{
143143
casePG_MD5:
144-
pg_md5_update(&ctx->data.md5,data,len);
144+
pg_md5_update(&ctx->md5,data,len);
145145
break;
146146
casePG_SHA1:
147-
pg_sha1_update(&ctx->data.sha1,data,len);
147+
pg_sha1_update(&ctx->sha1,data,len);
148148
break;
149149
casePG_SHA224:
150-
pg_sha224_update(&ctx->data.sha224,data,len);
150+
pg_sha224_update(&ctx->sha224,data,len);
151151
break;
152152
casePG_SHA256:
153-
pg_sha256_update(&ctx->data.sha256,data,len);
153+
pg_sha256_update(&ctx->sha256,data,len);
154154
break;
155155
casePG_SHA384:
156-
pg_sha384_update(&ctx->data.sha384,data,len);
156+
pg_sha384_update(&ctx->sha384,data,len);
157157
break;
158158
casePG_SHA512:
159-
pg_sha512_update(&ctx->data.sha512,data,len);
159+
pg_sha512_update(&ctx->sha512,data,len);
160160
break;
161161
}
162162

@@ -182,47 +182,47 @@ pg_cryptohash_final(pg_cryptohash_ctx *ctx, uint8 *dest, size_t len)
182182
ctx->error=PG_CRYPTOHASH_ERROR_DEST_LEN;
183183
return-1;
184184
}
185-
pg_md5_final(&ctx->data.md5,dest);
185+
pg_md5_final(&ctx->md5,dest);
186186
break;
187187
casePG_SHA1:
188188
if (len<SHA1_DIGEST_LENGTH)
189189
{
190190
ctx->error=PG_CRYPTOHASH_ERROR_DEST_LEN;
191191
return-1;
192192
}
193-
pg_sha1_final(&ctx->data.sha1,dest);
193+
pg_sha1_final(&ctx->sha1,dest);
194194
break;
195195
casePG_SHA224:
196196
if (len<PG_SHA224_DIGEST_LENGTH)
197197
{
198198
ctx->error=PG_CRYPTOHASH_ERROR_DEST_LEN;
199199
return-1;
200200
}
201-
pg_sha224_final(&ctx->data.sha224,dest);
201+
pg_sha224_final(&ctx->sha224,dest);
202202
break;
203203
casePG_SHA256:
204204
if (len<PG_SHA256_DIGEST_LENGTH)
205205
{
206206
ctx->error=PG_CRYPTOHASH_ERROR_DEST_LEN;
207207
return-1;
208208
}
209-
pg_sha256_final(&ctx->data.sha256,dest);
209+
pg_sha256_final(&ctx->sha256,dest);
210210
break;
211211
casePG_SHA384:
212212
if (len<PG_SHA384_DIGEST_LENGTH)
213213
{
214214
ctx->error=PG_CRYPTOHASH_ERROR_DEST_LEN;
215215
return-1;
216216
}
217-
pg_sha384_final(&ctx->data.sha384,dest);
217+
pg_sha384_final(&ctx->sha384,dest);
218218
break;
219219
casePG_SHA512:
220220
if (len<PG_SHA512_DIGEST_LENGTH)
221221
{
222222
ctx->error=PG_CRYPTOHASH_ERROR_DEST_LEN;
223223
return-1;
224224
}
225-
pg_sha512_final(&ctx->data.sha512,dest);
225+
pg_sha512_final(&ctx->sha512,dest);
226226
break;
227227
}
228228

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp