Skip to content

Commit 856787c

Browse files
committed
Fixed some gcc warnings beyond -Wall
CVS-ID: phc.c 1.3 CVS-ID: tests.c 1.4 CVS-ID: userom.c 1.4 CVS-ID: yescrypt-common.c 1.2 CVS-ID: yescrypt-opt.c 1.9 CVS-ID: yescrypt-ref.c 1.6
1 parent 6bf917d commit 856787c

File tree

6 files changed

+31
-31
lines changed

6 files changed

+31
-31
lines changed

phc.c

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*-
2-
* Copyright 2014-2016 Alexander Peslyak
2+
* Copyright 2014-2016,2018 Alexander Peslyak
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
@@ -88,9 +88,8 @@ static void print_all_PHS(unsigned int t_cost, unsigned int m_cost)
8888
clock_t clk_tck = sysconf(_SC_CLK_TCK);
8989
struct tms start_tms, end_tms;
9090
clock_t start = times(&start_tms), end, start_v, end_v;
91-
const int count = 0x102;
92-
size_t inlen;
93-
int i, j;
91+
const size_t count = 0x102;
92+
size_t inlen, i, j;
9493

9594
inlen = 0;
9695
for (i = 0; i < count; i++) {
@@ -127,7 +126,7 @@ static void print_all_PHS(unsigned int t_cost, unsigned int m_cost)
127126
(unsigned long long)count, (double)(end - start) / clk_tck);
128127
}
129128

130-
int main(int argc, const char * const *argv)
129+
int main(void)
131130
{
132131
#if 0
133132
setvbuf(stdout, NULL, _IOLBF, 0);

tests.c

+10-12
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ static void print_PBKDF2_SHA256_raw(const char *passwd, size_t passwdlen,
5050
const char *salt, size_t saltlen, uint64_t c, size_t dkLen)
5151
{
5252
uint8_t dk[64];
53-
int i;
53+
size_t i;
5454

5555
assert(dkLen <= sizeof(dk));
5656

@@ -83,7 +83,7 @@ static void print_scrypt(const char *passwd, const char *salt,
8383
uint64_t N, uint32_t r, uint32_t p)
8484
{
8585
uint8_t dk[64];
86-
int i;
86+
size_t i;
8787

8888
printf("scrypt(\"%s\", \"%s\", %llu, %u, %u) =",
8989
passwd, salt, (unsigned long long)N, r, p);
@@ -107,9 +107,9 @@ static void print_yescrypt(const char *passwd, const char *salt,
107107
uint32_t dklen)
108108
{
109109
yescrypt_local_t local;
110-
yescrypt_params_t params = {flags, N, r, p, t, g};
110+
yescrypt_params_t params = {flags, N, r, p, t, g, 0};
111111
uint8_t dk[64];
112-
int i;
112+
uint32_t i;
113113

114114
#if 1
115115
/* Don't test hash upgrades */
@@ -141,7 +141,7 @@ static void print_yescrypt(const char *passwd, const char *salt,
141141
}
142142
#endif
143143

144-
int main(int argc, const char * const *argv)
144+
int main(void)
145145
{
146146
int i;
147147

@@ -234,7 +234,7 @@ int main(int argc, const char * const *argv)
234234
N_log2++;
235235
}
236236
yescrypt_params_t params =
237-
{flags, (uint64_t)1 << N_log2, r, p};
237+
{flags, (uint64_t)1 << N_log2, r, p, 0, 0, 0};
238238
setting = yescrypt_encode_params(&params,
239239
(const uint8_t *)"WZaPV7LSUEKMo34.", 16 - (i & 15));
240240
if (i == 0)
@@ -361,11 +361,9 @@ int main(int argc, const char * const *argv)
361361

362362
shared.aligned_size = ((uint64_t)1 << NROM_log2) * 128 * r;
363363
shared.base_size = shared.aligned_size + 63;
364-
shared.base = malloc(shared.base_size);
365-
shared.aligned = (uint8_t *)shared.base + 63;
366-
shared.aligned -= (uintptr_t)shared.aligned & 63;
367-
368-
void *where = shared.aligned;
364+
uint8_t *where = shared.base = malloc(shared.base_size);
365+
where += 63;
366+
where = shared.aligned = where - ((uintptr_t)where & 63);
369367

370368
printf("Initializing ROM in preallocated memory ...");
371369
fflush(stdout);
@@ -379,7 +377,7 @@ int main(int argc, const char * const *argv)
379377
printf(" DONE (%02x%02x%02x%02x)\n",
380378
digest->uc[0], digest->uc[1], digest->uc[2], digest->uc[3]);
381379

382-
if (where != shared.aligned)
380+
if ((void *)where != shared.aligned)
383381
puts("YESCRYPT_SHARED_PREALLOCATED failed");
384382
#endif
385383

userom.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -321,15 +321,15 @@ int main(int argc, const char * const *argv)
321321
thread_data_s *td = &thread_data[omp_get_thread_num()].s;
322322
uint64_t start1 = time_us();
323323
#if 1
324-
const uint8_t *h = yescrypt_r(shared,
325-
&td->local,
324+
const char *h = (const char *)yescrypt_r(
325+
shared, &td->local,
326326
(const uint8_t *)p, strlen(p),
327327
setting, &key, hash, sizeof(hash));
328328
#else
329329
yescrypt_local_t local;
330330
yescrypt_init_local(&local);
331-
const uint8_t *h = yescrypt_r(shared,
332-
&local,
331+
const char *h = (const char *)yescrypt_r(
332+
shared, &local,
333333
(const uint8_t *)p, strlen(p),
334334
setting, &key, hash, sizeof(hash));
335335
yescrypt_free_local(&local);
@@ -343,10 +343,10 @@ int main(int argc, const char * const *argv)
343343
td->min = diff1;
344344
if (diff1 > td->max)
345345
td->max = diff1;
346-
if (j < nsave && strcmp(save[j], (char *)h)) {
346+
if (j < nsave && strcmp(save[j], h)) {
347347
#pragma omp critical
348348
printf("Mismatch at %u, %s != %s\n",
349-
j, save[j], (char *)h);
349+
j, save[j], h);
350350
}
351351
}
352352

yescrypt-common.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ uint8_t *yescrypt_r(const yescrypt_shared_t *shared, yescrypt_local_t *local,
428428
saltlen = sizeof(saltbin);
429429
saltend = decode64(saltbin, &saltlen, saltstr, saltstrlen);
430430

431-
if (!saltend || saltend - saltstr != saltstrlen)
431+
if (!saltend || (size_t)(saltend - saltstr) != saltstrlen)
432432
goto fail;
433433

434434
salt = saltbin;

yescrypt-opt.c

+8-6
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,12 @@ static inline void salsa20_simd_unshuffle(const salsa20_blk_t *Bin,
194194
* Apply the Salsa20 core to the block provided in (X0 ... X3).
195195
*/
196196
#define SALSA20_wrapper(out, rounds) { \
197-
__m128i Y0 = X0, Y1 = X1, Y2 = X2, Y3 = X3; \
197+
__m128i Z0 = X0, Z1 = X1, Z2 = X2, Z3 = X3; \
198198
rounds \
199-
(out).q[0] = X0 = _mm_add_epi32(X0, Y0); \
200-
(out).q[1] = X1 = _mm_add_epi32(X1, Y1); \
201-
(out).q[2] = X2 = _mm_add_epi32(X2, Y2); \
202-
(out).q[3] = X3 = _mm_add_epi32(X3, Y3); \
199+
(out).q[0] = X0 = _mm_add_epi32(X0, Z0); \
200+
(out).q[1] = X1 = _mm_add_epi32(X1, Z1); \
201+
(out).q[2] = X2 = _mm_add_epi32(X2, Z2); \
202+
(out).q[3] = X3 = _mm_add_epi32(X3, Z3); \
203203
}
204204

205205
/**
@@ -1395,8 +1395,10 @@ int yescrypt_kdf(const yescrypt_shared_t *shared, yescrypt_local_t *local,
13951395
retval = yescrypt_kdf_body(shared, local,
13961396
passwd, passwdlen, salt, saltlen,
13971397
flags, N, r, p, t, NROM, buf, buflen);
1398+
#ifndef SKIP_MEMZERO
13981399
if (passwd == dk)
13991400
insecure_memzero(dk, sizeof(dk));
1401+
#endif
14001402
return retval;
14011403
}
14021404

@@ -1440,7 +1442,7 @@ int yescrypt_init_shared(yescrypt_shared_t *shared,
14401442
half1 = *shared;
14411443
half1.aligned_size /= 2;
14421444
half2 = half1;
1443-
half2.aligned += half1.aligned_size;
1445+
half2.aligned = (uint8_t *)half2.aligned + half1.aligned_size;
14441446

14451447
if (yescrypt_kdf(NULL, &half1,
14461448
seed, seedlen, (uint8_t *)"yescrypt-ROMhash", 16, &subparams,

yescrypt-ref.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ int yescrypt_init_shared(yescrypt_shared_t *shared,
825825

826826
half1 = half2 = *shared;
827827
half1.aligned_size /= 2;
828-
half2.aligned += half1.aligned_size;
828+
half2.aligned = (uint8_t *)half2.aligned + half1.aligned_size;
829829
half2.aligned_size = half1.aligned_size;
830830
N /= 2;
831831

@@ -918,5 +918,6 @@ int yescrypt_init_local(yescrypt_local_t *local)
918918
int yescrypt_free_local(yescrypt_local_t *local)
919919
{
920920
/* The reference implementation frees its memory in yescrypt_kdf() */
921+
(void)local; /* unused */
921922
return 0;
922923
}

0 commit comments

Comments
 (0)