Constify "identifier" in struct custom_operations (#2240)

Because otherwise it is not possible to initialize it with a constant
C string when compiling with a C++ compiler without getting a warning:

    ISO C++11 does not allow conversion from string literal to 'char *'
      [-Wwritable-strings]

No tests seams to be more annoyed by this change but of course it is
always possible that some code in the wild relies on this field to be
non-const. This is indeed an API change, although a trivial one.
master
Cedric Cellier 2019-02-28 16:32:55 +01:00 committed by Xavier Leroy
parent 1626a018d8
commit 30f2cb1d81
3 changed files with 5 additions and 2 deletions

View File

@ -29,6 +29,9 @@ Working version
- GPR#1725: Deprecate Obj.set_tag
(Stephen Dolan, review by Gabriel Scherer and Damien Doligez)
* GPR#2240: Constify "identifier" in struct custom_operations
(Cedric Cellier, review by Xavier Leroy)
### Other libraries:
- GPR#2248: Unix alloc_sockaddr: Fix read of uninitialized memory for an

View File

@ -28,7 +28,7 @@ struct custom_fixed_length {
};
struct custom_operations {
char *identifier;
char const *identifier;
void (*finalize)(value v);
int (*compare)(value v1, value v2);
intnat (*hash)(value v);

View File

@ -537,7 +537,7 @@ static void extern_rec(value v)
case Custom_tag: {
uintnat sz_32, sz_64;
char * size_header;
char * ident = Custom_ops_val(v)->identifier;
char const * ident = Custom_ops_val(v)->identifier;
void (*serialize)(value v, uintnat * bsize_32,
uintnat * bsize_64)
= Custom_ops_val(v)->serialize;