s3:registry: Fix size types and length calculations
authorAndreas Schneider <asn@samba.org>
Thu, 7 Dec 2017 18:46:21 +0000 (19:46 +0100)
committerJeremy Allison <jra@samba.org>
Wed, 21 Mar 2018 03:25:39 +0000 (04:25 +0100)
This fixes compilation with -Wstrict-overflow=2

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Wed Mar 21 04:25:39 CET 2018 on sn-devel-144

source3/registry/reg_format.c

index 15f63c7c06a2c46cf37328dfe5393431c4b4e152..36ccb6261949b6fc81af07b4668499ed86bcd75d 100644 (file)
@@ -54,16 +54,17 @@ static void cstr_unescape(char* val)
  * @see srprs_val_name
  */
 static int cbuf_print_value_assign(cbuf* ost, const char* name) {
-       int ret, n;
+       size_t ret = 0;
+       int n;
        if (*name == '\0') {
-               ret = cbuf_putc(ost, '@');
+               n = cbuf_putc(ost, '@');
        } else {
-               ret = cbuf_print_quoted_string(ost, name);
+               n = cbuf_print_quoted_string(ost, name);
        }
-
-       if (ret<0) {
-               return ret;
+       if (n < 0) {
+               return n;
        }
+       ret += n;
 
        n = cbuf_putc(ost, '=');
        if (n < 0) {
@@ -120,7 +121,8 @@ cbuf_print_hive(cbuf* ost, const char* hive, int len, const struct fmt_key* fmt)
 static int
 cbuf_print_keyname(cbuf* ost, const char* key[], int n, const struct fmt_key* fmt)
 {
-       int r, ret=0;
+       int r;
+       size_t ret = 0;
        size_t pos = cbuf_getpos(ost);
        bool hive = true;