Skip to content

Commit d169aa2

Browse files
authored
Merge pull request #290 from libtom/pr/write-strings
Add -Wwrite-strings (char* vs. const char*)
2 parents 565be29 + b281348 commit d169aa2

8 files changed

Lines changed: 14 additions & 13 deletions

File tree

makefile_include.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ LTC_CFLAGS += -Wextra
7070
LTC_CFLAGS += -Wsystem-headers -Wbad-function-cast -Wcast-align
7171
LTC_CFLAGS += -Wstrict-prototypes -Wpointer-arith
7272
LTC_CFLAGS += -Wdeclaration-after-statement
73+
LTC_CFLAGS += -Wwrite-strings
7374
endif
7475

7576
LTC_CFLAGS += -Wno-type-limits

src/headers/tomcrypt_argchk.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#define NORETURN
2121
#endif
2222

23-
void crypt_argchk(char *v, char *s, int d) NORETURN;
23+
void crypt_argchk(const char *v, const char *s, int d) NORETURN;
2424
#define LTC_ARGCHK(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
2525
#define LTC_ARGCHKVD(x) do { if (!(x)) { crypt_argchk(#x, __FILE__, __LINE__); } }while(0)
2626

src/headers/tomcrypt_cipher.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ typedef struct {
349349
/** cipher descriptor table, last entry has "name == NULL" to mark the end of table */
350350
extern struct ltc_cipher_descriptor {
351351
/** name of cipher */
352-
char *name;
352+
const char *name;
353353
/** internal ID */
354354
unsigned char ID;
355355
/** min keysize (octets) */

src/headers/tomcrypt_hash.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ typedef union Hash_state {
204204
/** hash descriptor */
205205
extern struct ltc_hash_descriptor {
206206
/** name of hash */
207-
char *name;
207+
const char *name;
208208
/** internal ID */
209209
unsigned char ID;
210210
/** Size of digest in octets */

src/headers/tomcrypt_math.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ int radix_to_bin(const void *in, int radix, void *out, unsigned long *len);
3535
/** math descriptor */
3636
typedef struct {
3737
/** Name of the math provider */
38-
char *name;
38+
const char *name;
3939

4040
/** Bits per digit, amount of bits must fit in an unsigned long */
4141
int bits_per_digit;

src/headers/tomcrypt_pk.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ int dh_export_key(void *out, unsigned long *outlen, int type, dh_key *key);
230230
#ifdef LTC_SOURCE
231231
typedef struct {
232232
int size;
233-
char *name, *base, *prime;
233+
const char *name, *base, *prime;
234234
} ltc_dh_set_type;
235235

236236
extern const ltc_dh_set_type ltc_dh_sets[];
@@ -257,22 +257,22 @@ typedef struct {
257257
int size;
258258

259259
/** name of curve */
260-
char *name;
260+
const char *name;
261261

262262
/** The prime that defines the field the curve is in (encoded in hex) */
263-
char *prime;
263+
const char *prime;
264264

265265
/** The fields B param (hex) */
266-
char *B;
266+
const char *B;
267267

268268
/** The order of the curve (hex) */
269-
char *order;
269+
const char *order;
270270

271271
/** The x co-ordinate of the base point on the curve (hex) */
272-
char *Gx;
272+
const char *Gx;
273273

274274
/** The y co-ordinate of the base point on the curve (hex) */
275-
char *Gy;
275+
const char *Gy;
276276
} ltc_ecc_set_type;
277277

278278
/** A point on a ECC curve, stored in Jacbobian format such that (x,y,z) => (x/z^2, y/z^3, 1) when interpretted as affine */

src/headers/tomcrypt_prng.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ typedef struct {
8181
/** PRNG descriptor */
8282
extern struct ltc_prng_descriptor {
8383
/** Name of the PRNG */
84-
char *name;
84+
const char *name;
8585
/** size in bytes of exported state */
8686
int export_size;
8787
/** Start a PRNG state

src/misc/crypt/crypt_argchk.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*/
1515

1616
#if (ARGTYPE == 0)
17-
void crypt_argchk(char *v, char *s, int d)
17+
void crypt_argchk(const char *v, const char *s, int d)
1818
{
1919
fprintf(stderr, "LTC_ARGCHK '%s' failure on line %d of file %s\n",
2020
v, d, s);

0 commit comments

Comments
 (0)