diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2014-03-17 14:28:40 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2014-03-17 14:28:40 (GMT) |
commit | f2aa62ec76993c04c807c27e7a577a1ac3b0da3f (patch) | |
tree | 8bfa87fd91e47b88afc4c98e2ba0c2c97e3a10f1 /hl | |
parent | 4ffe2f78c524e8edfc4be77117187870a5fd5a7a (diff) | |
download | hdf5-f2aa62ec76993c04c807c27e7a577a1ac3b0da3f.zip hdf5-f2aa62ec76993c04c807c27e7a577a1ac3b0da3f.tar.gz hdf5-f2aa62ec76993c04c807c27e7a577a1ac3b0da3f.tar.bz2 |
[svn-r24810] Description:
Bring r24803 & r24804 from trunk to 1.8 branch:
r24804:
Brought changes from Coverity branch back to trunk, and cleaned up misc.
other warnings & formatting issues:
r20833:
Fixed Coverity 667 and 668 with real integer overflow tests this time.
r20834:
Use HDstrncpy and HDstrncat. --gh
r20835:
Change to use strncpy - use base_len + 1 for line 156, use HDstrlen(path) + 1 for line 159
r20836:
Fixed coverity 585 by casting output of fgetc() to a char.
r20837:
Changed sprintf calls to snprintf with size 1 less than the allocated buffer to address coverity issue #967.
r24803:
Rename GCC_DIAG_OFF/ON macros to H5_GCC_DIAG_OFF/ON and move from
src/H5private.h to src/H5public.h. Wrap typedef of hsize_t and hssize_t
in DIAG_OFF(long-long) macros.
Clean up a bunch of "macro '-' is unused" warnings.
Tested on:
Mac OSX/64 10.9.2 (amazon) w/C++, FORTRAN & parallel
(too minor to require h5committest)
Diffstat (limited to 'hl')
-rw-r--r-- | hl/test/test_image.c | 24 | ||||
-rw-r--r-- | hl/tools/gif2h5/decompress.c | 6 | ||||
-rw-r--r-- | hl/tools/gif2h5/gif2mem.c | 2 | ||||
-rw-r--r-- | hl/tools/gif2h5/hdfgifwr.c | 65 |
4 files changed, 14 insertions, 83 deletions
diff --git a/hl/test/test_image.c b/hl/test/test_image.c index 5a52980..d2d9cab 100644 --- a/hl/test/test_image.c +++ b/hl/test/test_image.c @@ -13,8 +13,10 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +#include <limits.h> #include <stdlib.h> #include <string.h> + #include "h5hltest.h" #include "H5srcdir.h" #include "H5LTpublic.h" @@ -634,10 +636,12 @@ static int test_generate(void) if(n_elements > INT_MAX / (int)sizeof(float)) goto out; - data = (float *)HDmalloc((size_t)n_elements * sizeof( float )); - HDassert(data); - image_data = (unsigned char *)HDmalloc((size_t)n_elements * sizeof( unsigned char )); - HDassert(image_data); + data = (float *)HDmalloc((size_t)n_elements * sizeof(float)); + if(NULL == data) + goto out; + image_data = (unsigned char *)HDmalloc((size_t)n_elements * sizeof(unsigned char)); + if(NULL == image_data) + goto out; for ( i = 0; i < n_elements; i++ ) { @@ -806,9 +810,6 @@ static int read_data( const char* fname, /*IN*/ fscanf(f, "%s", str); fscanf(f, "%d", &w); - *width = (hsize_t)w; - *height = (hsize_t)h; - /* Check product for overflow */ if(w < 1 || h < 1 || color_planes < 1) goto out; @@ -825,13 +826,16 @@ static int read_data( const char* fname, /*IN*/ goto out; /* Release the buffer, if it was previously allocated */ - if(image_data) { + if(image_data) HDfree(image_data); - image_data = NULL; - } /* end if */ /* Allocate the image data buffer */ image_data = (unsigned char *)HDmalloc((size_t)n_elements * sizeof(unsigned char)); + if(NULL == image_data) + goto out; + + *width = (hsize_t)w; + *height = (hsize_t)h; /* Read data elements */ for(i = 0; i < n_elements; i++) { diff --git a/hl/tools/gif2h5/decompress.c b/hl/tools/gif2h5/decompress.c index 2e44f1c..d4e4cdc 100644 --- a/hl/tools/gif2h5/decompress.c +++ b/hl/tools/gif2h5/decompress.c @@ -17,12 +17,6 @@ #include "gif.h" -#define NEXTBYTE (*ptr++) - -#define IMAGESEP 0x2c -#define INTERLACEMASK 0x40 -#define COLORMAPMASK 0x80 - WORD iWIDE, iHIGH, eWIDE, eHIGH, expand, numcols, strip, nostrip; unsigned long cols[256]; char *cmd; diff --git a/hl/tools/gif2h5/gif2mem.c b/hl/tools/gif2h5/gif2mem.c index 7995bb4..ac4b0ec 100644 --- a/hl/tools/gif2h5/gif2mem.c +++ b/hl/tools/gif2h5/gif2mem.c @@ -37,8 +37,6 @@ #include "gif.h" -#define GIF2VERSION "1.00" - GIFTOMEM Gif2Mem(BYTE *MemGif) { diff --git a/hl/tools/gif2h5/hdfgifwr.c b/hl/tools/gif2h5/hdfgifwr.c index 1771d06..d828226 100644 --- a/hl/tools/gif2h5/hdfgifwr.c +++ b/hl/tools/gif2h5/hdfgifwr.c @@ -56,31 +56,6 @@ typedef BYTE byte; typedef long int count_int; -/* indicies into conv24MB */ -#define CONV24_8BIT 0 -#define CONV24_24BIT 1 -#define CONV24_SEP1 2 -#define CONV24_LOCK 3 -#define CONV24_SEP2 4 -#define CONV24_FAST 5 -#define CONV24_SLOW 6 -#define CONV24_BEST 7 -#define CONV24_MAX 8 - -/* values 'picType' can take */ -#define PIC8 CONV24_8BIT -#define PIC24 CONV24_24BIT - -/* MONO returns total intensity of r,g,b components */ -#define MONO(rd,gn,bl) (((rd)*11 + (gn)*16 + (bl)*5) >> 5) /*.33R+ .5G+ .17B*/ - -#ifdef UNUSED -static int Width, Height; -static int curx, cury; -static long CountDown; -static int Interlace; -#endif /* UNUSED */ - #ifdef __STDC__ static void compress(int, FILE *, byte *, int); static void output(int); @@ -95,20 +70,12 @@ static void char_init(), char_out(), flush_char(); #endif /* __STDC__ */ static byte pc2nc[256]; -#ifdef UNUSED -static byte r1[256],g1[256],b1[256]; -#endif /* UNUSED */ /*************************************************************/ int hdfWriteGIF(FILE *fp, byte *pic, int ptype, int w, int h, byte *rmap, byte *gmap, byte *bmap, byte *pc2ncmap, int numcols, int colorstyle, int BitsPerPixel) { -#ifdef UNUSED - int RWidth, RHeight; - int LeftOfs, TopOfs; - int ColorMapSize, Background; -#endif /* UNUSED */ int InitCodeSize; int i; byte *pic8 = pic; @@ -121,39 +88,15 @@ int hdfWriteGIF(FILE *fp, byte *pic, int ptype, int w, int h, byte *rmap, numcols=numcols; colorstyle=colorstyle; -#ifdef UNUSED - Interlace = 0; - Background = 0; -#endif /* UNUSED */ - for (i = 0; i < 256; i++) { pc2nc[i] = pc2ncmap[i]; -#ifdef UNUSED - r1[i] = rmap[i]; - g1[i] = gmap[i]; - b1[i] = bmap[i]; -#endif /* UNUSED */ } -#ifdef UNUSED - ColorMapSize = 1 << BitsPerPixel; - - RWidth = Width = w; - RHeight = Height = h; - LeftOfs = TopOfs = 0; - - CountDown = w * h; /* # of pixels we'll be doing */ -#endif /* UNUSED */ - if (BitsPerPixel <= 1) InitCodeSize = 2; else InitCodeSize = BitsPerPixel; -#ifdef UNUSED - curx = cury = 0; -#endif /* UNUSED */ - if (!fp) { fprintf(stderr, "WriteGIF: file not open for writing\n" ); return (1); @@ -172,11 +115,7 @@ static unsigned long cur_accum = 0; static int cur_bits = 0; #define MAXCODE(n_bits) ( (1 << (n_bits)) - 1) -#ifndef min -#define min(a,b) ((a>b) ? b : a) -#endif /* min */ #define XV_BITS 12 /* BITS was already defined on some systems */ -#define MSDOS 1 #define HSIZE 5003 /* 80% occupancy */ typedef unsigned char char_type; @@ -203,10 +142,6 @@ static int hsize = HSIZE; /* for dynamic table sizing */ * used to be 8000 characters). */ -#define tab_prefixof(i) CodeTabOf(i) -#define tab_suffixof(i) ((char_type *)(htab))[i] -#define de_stack ((char_type *)&tab_suffixof(1<<XV_BITS)) - static int free_ent = 0; /* first unused entry */ /* |