Browse code

eliminating warnings that cropped up in 32bit ubuntu (16.04)

Micah Snyder authored on 2017/09/01 00:00:34
Showing 5 changed files
... ...
@@ -1,5 +1,5 @@
1 1
 /*
2
- *  Copyright (C) 2015 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
2
+ *  Copyright (C) 2015, 2017 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
3 3
  *  Copyright (C) 2007-2009 Sourcefire, Inc.
4 4
  *
5 5
  *  Authors: Tomasz Kojm, Trog, Török Edvin
... ...
@@ -437,7 +437,7 @@ static void *acceptloop_th(void *arg)
437 437
 	    } else if (errno != EINTR) {
438 438
 		/* very bad - need to exit or restart */
439 439
 #ifdef HAVE_STRERROR_R
440
-		strerror_r(errno, buff, BUFFSIZE);
440
+		(void)strerror_r(errno, buff, BUFFSIZE);
441 441
 		logg("!accept() failed: %s\n", buff);
442 442
 #else
443 443
 		logg("!accept() failed\n");
... ...
@@ -1393,11 +1393,11 @@ static int parseBB(struct cli_bc *bc, unsigned func, unsigned bb, unsigned char
1393 1393
 	offset++;
1394 1394
     }
1395 1395
     if (buffer[offset] == 'D') {
1396
-	unsigned num;
1396
+		uint32_t num;
1397 1397
 	offset += 3;
1398 1398
 	if (offset >= len)
1399 1399
 	    return CL_EMALFDB;
1400
-	num = readNumber(buffer, &offset, len, &ok);
1400
+	num = (uint32_t)readNumber(buffer, &offset, len, &ok);
1401 1401
 	if (!ok)
1402 1402
 	    return CL_EMALFDB;
1403 1403
 	if (num != bcfunc->numInsts) {
... ...
@@ -1406,10 +1406,10 @@ static int parseBB(struct cli_bc *bc, unsigned func, unsigned bb, unsigned char
1406 1406
 	}
1407 1407
 	bcfunc->dbgnodes = cli_malloc(num*sizeof(*bcfunc->dbgnodes));
1408 1408
 	if (!bcfunc->dbgnodes) {
1409
-        cli_errmsg("Unable to allocate memory for dbg nodes: %lu\n", num*sizeof(*bcfunc->dbgnodes));
1409
+        cli_errmsg("Unable to allocate memory for dbg nodes: %u\n", num * (uint32_t)sizeof(*bcfunc->dbgnodes));
1410 1410
 	    return CL_EMEM;
1411 1411
     }
1412
-	for (i=0;i<num;i++) {
1412
+	for (i=0; (uint32_t)i < num; i++) {
1413 1413
 	    bcfunc->dbgnodes[i] = readNumber(buffer, &offset, len, &ok);
1414 1414
 	    if (!ok)
1415 1415
 		return CL_EMALFDB;
... ...
@@ -2071,7 +2071,7 @@ static int cli_bytecode_prepare_interpreter(struct cli_bc *bc)
2071 2071
     bc->numGlobalBytes = 0;
2072 2072
     gmap = cli_malloc(bc->num_globals*sizeof(*gmap));
2073 2073
     if (!gmap) {
2074
-        cli_errmsg("interpreter: Unable to allocate memory for global map: %lu\n", bc->num_globals*sizeof(*gmap));
2074
+        cli_errmsg("interpreter: Unable to allocate memory for global map: %zu\n", bc->num_globals*sizeof(*gmap));
2075 2075
         return CL_EMEM;
2076 2076
     }
2077 2077
     for (j=0;j<bc->num_globals;j++) {
... ...
@@ -2151,9 +2151,9 @@ static int cli_bytecode_prepare_interpreter(struct cli_bc *bc)
2151 2151
     for (i=0;i<bc->num_func && ret == CL_SUCCESS;i++) {
2152 2152
 	struct cli_bc_func *bcfunc = &bc->funcs[i];
2153 2153
 	unsigned totValues = bcfunc->numValues + bcfunc->numConstants + bc->num_globals;
2154
-	unsigned *map = cli_malloc(sizeof(*map)*totValues);
2154
+	unsigned *map = cli_malloc(sizeof(*map) * (size_t)totValues);
2155 2155
 	if (!map) {
2156
-        cli_errmsg("interpreter: Unable to allocate memory for map: %lu\n", sizeof(*map)*totValues);
2156
+        cli_errmsg("interpreter: Unable to allocate memory for map: %zu\n", sizeof(*map) * (size_t)totValues);
2157 2157
         free(gmap);
2158 2158
 	    return CL_EMEM;
2159 2159
     }
... ...
@@ -5,7 +5,7 @@
5 5
  *                          Greg Roelofs <newt@pobox.com>,
6 6
  *                          John Bowler <jbowler@acm.org>,
7 7
  *                          Tom Lane <tgl@sss.pgh.pa.us>
8
- *   Copyright (C) 2015 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
8
+ *   Copyright (C) 2015, 2017 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
9 9
  *   Copyright (C) 2011 Sourcefire, Inc.
10 10
  *   Maintainer: Tomasz Kojm <tkojm@clamav.net>
11 11
  *
... ...
@@ -710,7 +710,7 @@ int cli_parsepng(cli_ctx *ctx)
710 710
             } else if (cur_y >= h) {
711 711
                 inflateEnd(&zstrm);
712 712
 		if(eod - p > 0) {
713
-		    cli_dbgmsg("PNG:  %ld bytes remaining in buffer before inflateEnd()", eod-p);
713
+		    cli_dbgmsg("PNG:  %u bytes remaining in buffer before inflateEnd()", (unsigned int)(eod - p));
714 714
 		    return CL_EPARSE;
715 715
 		}
716 716
 		err = Z_STREAM_END;
... ...
@@ -439,7 +439,7 @@ int unspin(char *src, int ssize, struct cli_exe_section *sections, int sectcnt,
439 439
     cli_dbgmsg("spin: Compression bitmap is %x\n", bitmap);
440 440
     if ((sects = (char **)cli_malloc(sectcnt * sizeof(char *))) == NULL)
441 441
     {
442
-        cli_dbgmsg("spin: malloc(%lu) failed\n", sectcnt * sizeof(char *));
442
+        cli_dbgmsg("spin: malloc(%zu) failed\n", (size_t)sectcnt * sizeof(char *));
443 443
         return 1;
444 444
     }
445 445
 
... ...
@@ -450,7 +450,7 @@ int unspin(char *src, int ssize, struct cli_exe_section *sections, int sectcnt,
450 450
         {
451 451
             if ((sects[j] = (char *)cli_malloc(sections[j].vsz)) == NULL)
452 452
             {
453
-                cli_dbgmsg("spin: malloc(%d) failed\n", sections[j].vsz);
453
+                cli_dbgmsg("spin: malloc(%u) failed\n", sections[j].vsz);
454 454
                 len = 1;
455 455
                 break;
456 456
             }
... ...
@@ -81,7 +81,7 @@ static int xar_get_numeric_from_xml_element(xmlTextReaderPtr reader, size_t * va
81 81
         if (numstr) {
82 82
             numval = atol((const char *)numstr);
83 83
             if (numval < 0) {
84
-                cli_dbgmsg("cli_scanxar: XML element value %li\n", *value);
84
+                cli_dbgmsg("cli_scanxar: XML element value %zu\n", *value);
85 85
                 return CL_EFORMAT;
86 86
             }
87 87
             *value = numval;
... ...
@@ -678,7 +678,7 @@ int cli_scanxar(cli_ctx *ctx)
678 678
                 if (blockp == NULL) {
679 679
                     char errbuff[128];
680 680
                     cli_strerror(errno, errbuff, sizeof(errbuff));
681
-                    cli_dbgmsg("cli_scanxar: Can't read %i bytes @ %li, errno:%s.\n",
681
+                    cli_dbgmsg("cli_scanxar: Can't read %i bytes @ %zu, errno:%s.\n",
682 682
                                CLI_LZMA_HDR_SIZE, at, errbuff);
683 683
                     rc = CL_EREAD;
684 684
                     __lzma_wrap_free(NULL, buff);
... ...
@@ -702,7 +702,7 @@ int cli_scanxar(cli_ctx *ctx)
702 702
 
703 703
                 at += CLI_LZMA_HDR_SIZE;
704 704
                 in_remaining -= CLI_LZMA_HDR_SIZE;
705
-                while ((size_t)at < map->len && (unsigned long)at < offset+hdr.toc_length_compressed+hdr.size+length) {
705
+                while (at < map->len && at < offset + (size_t)hdr.toc_length_compressed + (size_t)hdr.size + length) {
706 706
                     SizeT avail_in;
707 707
                     SizeT avail_out;
708 708
                     void * next_in;
... ...
@@ -715,7 +715,7 @@ int cli_scanxar(cli_ctx *ctx)
715 715
                     if (lz.next_in == NULL) {
716 716
                         char errbuff[128];
717 717
                         cli_strerror(errno, errbuff, sizeof(errbuff));
718
-                        cli_dbgmsg("cli_scanxar: Can't read %li bytes @ %li, errno: %s.\n",
718
+                        cli_dbgmsg("cli_scanxar: Can't read %zu bytes @ %zu, errno: %s.\n",
719 719
                                    lz.avail_in, at, errbuff);
720 720
                         rc = CL_EREAD;
721 721
                         __lzma_wrap_free(NULL, buff);
... ...
@@ -799,7 +799,7 @@ int cli_scanxar(cli_ctx *ctx)
799 799
                     xar_hash_update(a_hash_ctx, blockp, writelen, a_hash);
800 800
                 
801 801
                 if (cli_writen(fd, blockp, writelen) < 0) {
802
-                    cli_dbgmsg("cli_scanxar: cli_writen error %zu bytes @ %li.\n", writelen, at);
802
+                    cli_dbgmsg("cli_scanxar: cli_writen error %zu bytes @ %zu.\n", writelen, at);
803 803
                     rc = CL_EWRITE;
804 804
                     goto exit_tmpfile;
805 805
                 }