From 5ed139f096a0bd8600d9df1c89ca2d1c136646c0 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 9 Jul 2005 12:51:44 +0000 Subject: r8261: charset style strings in pidl should be const, just like old style ndr strings (This used to be commit aa0e1d6699959571963d6e6fb455b33c4436dcdf) --- source4/build/pidl/ndr_header.pm | 2 +- source4/librpc/ndr/ndr_string.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/source4/build/pidl/ndr_header.pm b/source4/build/pidl/ndr_header.pm index 33183cec96..0e0d4f5725 100644 --- a/source4/build/pidl/ndr_header.pm +++ b/source4/build/pidl/ndr_header.pm @@ -214,7 +214,7 @@ sub HeaderType($$$) } if (util::has_property($e, "charset")) { - pidl "char"; + pidl "const char"; } else { pidl typelist::mapType($e->{TYPE}); } diff --git a/source4/librpc/ndr/ndr_string.c b/source4/librpc/ndr/ndr_string.c index 42316a8003..11397aaafd 100644 --- a/source4/librpc/ndr/ndr_string.c +++ b/source4/librpc/ndr/ndr_string.c @@ -590,11 +590,11 @@ void ndr_print_string_array(struct ndr_print *ndr, const char *name, const char } /* Return number of elements in a string including the last (zeroed) element */ -uint32_t ndr_string_length(void *_var, uint32_t element_size) +uint32_t ndr_string_length(const void *_var, uint32_t element_size) { uint32_t i; uint8_t zero[4] = {0,0,0,0}; - char *var = _var; + const char *var = _var; for (i = 0; memcmp(var+i*element_size,zero,element_size) != 0; i++); @@ -618,14 +618,14 @@ NTSTATUS ndr_check_string_terminator(struct ndr_pull *ndr, const void *_var, uin } -NTSTATUS ndr_pull_charset(struct ndr_pull *ndr, int ndr_flags, char **var, uint32_t length, uint8_t byte_mul, int chset) +NTSTATUS ndr_pull_charset(struct ndr_pull *ndr, int ndr_flags, const char **var, uint32_t length, uint8_t byte_mul, int chset) { int ret; NDR_PULL_NEED_BYTES(ndr, length*byte_mul); ret = convert_string_talloc(ndr, chset, CH_UNIX, ndr->data+ndr->offset, length*byte_mul, - (void **)var); + discard_const_p(void *, var)); if (ret == -1) { return ndr_pull_error(ndr, NDR_ERR_CHARCNV, "Bad character conversion"); -- cgit