It's nice to see more of our codebase starting to make use of language features introduced 20 years ago... ;)
Reviewed-by: Jeremy Huddleston <[email protected]> On Nov 9, 2011, at 10:19 PM, Alan Coopersmith wrote: > plus a bonus cleanup of ancient cruft noticed in the process. > > Changes the definition of one public API function to take const char * > arguments instead of char *, otherwise all changes are internal API or > local functions only. > > Before this series, there were 62 -Wwrite-strings warnings in libICE. > > After this series, there remain 3 unfixed -Wwrite-strings warnings, > which need more investigation - if anyone feels like pitching in, > please feel free to do so: > > process.c: In function 'ProcessError': > process.c:718:23: warning: initialization discards qualifiers from pointer > target type > > char *errorStr = ""; > > errorStr has to be non-const since it's returned to the caller via > errorReply->error_message, and the caller is responsible for freeing it. > I'm not sure if this should be replaced by setting the pointer to NULL > or to strdup(""), but we'd only want to do the strdup in the default case > of the switch statement that follows so we didn't leak in the other cases > that overwrite errorStr, and I'm not sure if even then it's needed. > > process.c: In function 'ProcessConnectionReply': > process.c:1794:32: warning: assignment discards qualifiers from pointer > target type > process.c: In function 'ProcessProtocolReply': > process.c:2298:32: warning: assignment discards qualifiers from pointer > target type > > Both of these are: > > errorReply->error_message = > "Received bad version index in Connection Reply"; > > I think this might be a bug, especially if the caller tries to free, but > I haven't walked back through the code path to find out. > > Alan Coopersmith (6): > Fix gcc -Wwrite-strings warnings in _IceDefaultErrorHandler > Fix gcc -Wwrite-strings warnings in _IceError* functions > constify arguments to IceGetAuthFileEntry > Fix gcc -Wwrite-strings warnings in AuthNames handling > Fix gcc -Wwrite-strings warnings in process.c > Remove ancient workaround for System V/386 Release 4.2 compiler bug > > doc/ICElib.xml | 6 ++-- > include/X11/ICE/ICEutil.h | 6 ++-- > src/ICElibint.h | 36 +++++++++++++++++----------------- > src/authutil.c | 6 ++-- > src/error.c | 45 ++++++++++++++++++++++--------------------- > src/getauth.c | 40 +++++++++++++++++++------------------- > src/globals.h | 2 +- > src/process.c | 47 +++++++++++++++++++------------------------- > src/protosetup.c | 2 +- > 9 files changed, 92 insertions(+), 98 deletions(-) > > -- > 1.7.3.2 > > _______________________________________________ > [email protected]: X.Org development > Archives: http://lists.x.org/archives/xorg-devel > Info: http://lists.x.org/mailman/listinfo/xorg-devel > _______________________________________________ [email protected]: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
