lib: param: Remove the last external use of global_iconv_handle by calling the utilit...
authorJeremy Allison <jra@samba.org>
Tue, 11 Apr 2017 22:57:28 +0000 (15:57 -0700)
committerAndreas Schneider <asn@cryptomilk.org>
Tue, 18 Apr 2017 09:47:17 +0000 (11:47 +0200)
commit2a4d07b999df2343c694a2b373d3b506bd3d5682
tree86ea1895229024857b9ba4fda30ad09e98cf041d
parent766e9ff05e0689b0c0284e33e044a363ed4a4709
lib: param: Remove the last external use of global_iconv_handle by calling the utility function reinit_iconv_handle().

Add an error check.

This *looks* like a logic change, but it is not.

The only change is the addition of the error return check.

The reason is that the changed function, reload_charcnv(),
is the *only* function that sets lp_ctx->iconv_handle. And
it does so just before setting global_iconv_handle = lp_ctx->iconv_handle.

Calling the utility function reinit_iconv_handle()
instead merely sets global_iconv_handle first, then
assigns it (as the return) to lp_ctx->iconv_handle.

So all this is doing is reversing the order of
setting global_iconv_handle and lp_ctx->iconv_handle
to the same thing.

Even the removal of the lines:

-       struct smb_iconv_handle *old_ic = lp_ctx->iconv_handle
-       if (old_ic == NULL) {
-               old_ic = global_iconv_handle;

has no effect, as remember that lp_ctx->iconv_handle
is only ever set to the same value as global_iconv_handle,
and once this function has been run once, lp_ctx->iconv_handle != NULL.

This allows us finally to make global_iconv_handle private
to the C source file that defines it.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
lib/param/loadparm.c