diff options
39 files changed, 486 insertions, 574 deletions
diff --git a/examples/h5_reference.c b/examples/h5_reference.c index 8445bb6..ddf98ac 100644 --- a/examples/h5_reference.c +++ b/examples/h5_reference.c @@ -37,7 +37,7 @@ main(void) { /* * Create group "A" in the file. */ - gid_a = H5Gcreate(fid, "A", -1); + gid_a = H5Gcreate(fid, "A", 0); /* * Create dataset "B" in the file. diff --git a/hl/tools/gif2h5/decompress.c b/hl/tools/gif2h5/decompress.c index 18dbb3e..abccb7f 100644 --- a/hl/tools/gif2h5/decompress.c +++ b/hl/tools/gif2h5/decompress.c @@ -19,13 +19,8 @@ static int BitOffset = 0, /* Bit Offset of next code */ XC = 0, YC = 0, /* Output X and Y coords of current pixel */ Pass = 0, /* Used by output routine if WORDerlaced pic */ OutCount = 0, /* Decompressor output 'stack count' */ -RWidth, RHeight, /* screen dimensions */ IWidth, IHeight, /* image dimensions */ -LeftOfs, TopOfs, /* image offset */ -BitsPerPixel, /* Bits per pixel, read from GIF header */ BytesPerScanline, /* Bytes per scanline in output raster */ -ColorMapSize, /* number of colors */ -Background, /* background color */ CodeSize, /* Code size, read from GIF header */ InitCodeSize, /* Starting code size, used during Clear */ Code, /* Value returned by ReadCode */ @@ -73,7 +68,7 @@ int numused; * three BYTEs, compute the bit Offset WORDo our 24-bit chunk, shift to * bring the desired code to the bottom, then mask it off and return it. */ -ReadCode() +static int ReadCode(void) { int RawCode, ByteOffset; @@ -87,8 +82,7 @@ ReadCode() } -AddToPixel(Index) -BYTE Index; +static void AddToPixel(BYTE Index) { if (YC<IHeight) *(Image + YC * BytesPerScanline + XC) = Index; @@ -202,7 +196,7 @@ GIFHEAD *GifHead; /* Allocate the Image */ - if (!(Image = (BYTE *)malloc(IWidth*IHeight))) { + if (!(Image = (BYTE *)malloc((size_t)IWidth*(size_t)IHeight))) { printf("Out of memory"); exit(-1); } diff --git a/hl/tools/gif2h5/gif.h b/hl/tools/gif2h5/gif.h index f697881..3f2a8da 100644 --- a/hl/tools/gif2h5/gif.h +++ b/hl/tools/gif2h5/gif.h @@ -169,7 +169,6 @@ int WriteHDF(GIFTOMEM , CHAR * , CHAR *); */ int ReadHDF(BYTE** data , BYTE palette[256][3] , hsize_t *image_size , CHAR *h5_file , CHAR *dset_name , CHAR *pal_name); -BYTE *ReadDataSubBlocks(BYTE ** , WORD *); BYTE *Decompress (GIFIMAGEDESC * , GIFHEAD *); BYTE GetByte(BYTE *); WORD GetWord(BYTE *); diff --git a/hl/tools/gif2h5/gif2hdf.c b/hl/tools/gif2h5/gif2hdf.c index 0211143..6b4ae2b 100644 --- a/hl/tools/gif2h5/gif2hdf.c +++ b/hl/tools/gif2h5/gif2hdf.c @@ -3,10 +3,9 @@ #include <string.h> #include <stdio.h> #include <stdlib.h> + int -main(argv , argc) -int argv; -char *argc[]; +main(int argv , char *argc[]) { GIFTOMEM GifMemoryStruct; @@ -60,11 +59,11 @@ char *argc[]; filesize = ftell(fpGif); fseek(fpGif, 0L , 0); if (filesize == 0) printf("File Size Zero"); - if (!(MemGif = StartPos = (BYTE *)malloc(filesize))) { + if (!(MemGif = StartPos = (BYTE *)malloc((size_t)filesize))) { printf("Out of memory"); exit (-1); } - if (fread(MemGif,filesize,1,fpGif) != 1) { + if (fread(MemGif,(size_t)filesize,1,fpGif) != 1) { printf("Corrupted Input File"); exit(-1); } diff --git a/hl/tools/gif2h5/gif2mem.c b/hl/tools/gif2h5/gif2mem.c index 92ca8e5..830eba7 100644 --- a/hl/tools/gif2h5/gif2mem.c +++ b/hl/tools/gif2h5/gif2mem.c @@ -25,7 +25,6 @@ /* #include <hdf.h> */ #define VERSION "1.00" -extern int EndianOrder; GIFTOMEM Gif2Mem(MemGif) diff --git a/hl/tools/gif2h5/gifread.c b/hl/tools/gif2h5/gifread.c index 1196241..cb033d9 100644 --- a/hl/tools/gif2h5/gifread.c +++ b/hl/tools/gif2h5/gifread.c @@ -3,14 +3,14 @@ #include "gif.h" int EndianOrder; -int i; +static BYTE * ReadDataSubBlocks(BYTE **MemGif2, WORD *DSize); WORD GetWord (MemGif) BYTE *MemGif; { - register WORD w; + WORD w; if (EndianOrder == 1) /* LittleEndian */ { w = (WORD) (*MemGif++ & 0xFF); @@ -46,14 +46,14 @@ ReadGifHeader(GifHead, MemGif2) GIFHEAD *GifHead; /* Pointer to GIF header structure */ BYTE **MemGif2; /* GIF image file input FILE stream */ { - register WORD i; /* Loop counter */ + WORD i; /* Loop counter */ WORD tableSize; /* Number of entires in the Global Color Table */ GifHead->TableSize = 0; for (i = 0 ; i < 6 ; i++) { GifHead->HeaderDump[i] = *(*MemGif2)++; } - if (strncmp(GifHead->HeaderDump , "GIF" , 3)) { + if (strncmp((const char *)GifHead->HeaderDump , "GIF" , 3)) { printf("The file does not appear to be a valid GIF file.\n"); exit(-1); } @@ -114,9 +114,9 @@ ReadGifImageDesc(GifImageDesc, MemGif2) GIFIMAGEDESC *GifImageDesc; /* Pointer to GIF image descriptor structure */ BYTE **MemGif2; /* GIF image file input FILE stream */ { - register WORD i; /* Loop counter */ + WORD i; /* Loop counter */ WORD tableSize; /* Number of entries in the Local Color Table */ - BYTE Interlace; /* PackedField & 0x20 gives information on interlacing */ + /* BYTE Interlace; */ /* PackedField & 0x20 gives information on interlacing */ BYTE *TempPtr; int ch , ch1; @@ -210,11 +210,11 @@ ReadGifGraphicControl(GifGraphicControl, MemGif2) GIFGRAPHICCONTROL *GifGraphicControl; /* Pointer to GC Extension structure */ BYTE **MemGif2; /* GIF image file input FILE stream */ { + int i; - - for (i = 0 ; i < 5 ; i++) { - GifGraphicControl->GCEDump[i] = *(*MemGif2)++; - } + for (i = 0 ; i < 5 ; i++) { + GifGraphicControl->GCEDump[i] = *(*MemGif2)++; + } return(0); /* No FILE stream error occured */ } @@ -234,6 +234,8 @@ ReadGifPlainText(GifPlainText, MemGif2) GIFPLAINTEXT *GifPlainText; /* Pointer to Plain Text Extension structure */ BYTE **MemGif2; /* GIF image file input FILE stream */ { + int i; + for (i = 0 ; i < 13 ; i++) { GifPlainText->PTEDump[i] = *(*MemGif2)++; } @@ -270,6 +272,8 @@ ReadGifApplication(GifApplication, MemGif2) GIFAPPLICATION *GifApplication; /* Pointer to Application Extension structure */ BYTE **MemGif2; /* GIF image file input FILE stream */ { + int i; + for (i = 0 ; i < 12 ; i++) { GifApplication->AEDump[i] = *(*MemGif2)++; } @@ -327,9 +331,8 @@ BYTE **MemGif2; /* GIF image file input FILE stream */ ** otherwise a valid pointer if no error occured. */ static BYTE * -ReadDataSubBlocks(MemGif2 , DSize) -BYTE **MemGif2; /* GIF image file input FILE stream */ -WORD *DSize; +ReadDataSubBlocks(BYTE **MemGif2, /* GIF image file input FILE stream */ + WORD *DSize) { BYTE *ptr1; /* Pointer used to "walk the heap" */ BYTE *ptr2; /* Pointer used to mark the top of the heap */ @@ -342,7 +345,7 @@ WORD *DSize; dataSize = *(*MemGif2)++; /* Get the size of the first sub-block */ /* Allocate initial data buffer */ - if (!(ptr1 = ptr2 = (BYTE *) malloc(dataSize + 1))) { + if (!(ptr1 = ptr2 = (BYTE *) malloc((size_t)dataSize + 1))) { printf("Out of memory. Allocation of memory for data sub-blocks for\neither Comment, Plain Text or Application Extensions failed"); return((BYTE *) NULL); } @@ -352,7 +355,9 @@ WORD *DSize; bufSize += (dataSize); /* Running total of the buffer size */ *DSize = bufSize; - /* *ptr1++ = dataSize; /* Write the data count */ +#ifdef COMMENTED_OUT + *ptr1++ = dataSize; /* Write the data count */ +#endif /* COMMENTED_OUT */ while (dataSize--) /* Read/write the Plain Text data */ *ptr1++ = *(*MemGif2)++; @@ -370,7 +375,9 @@ WORD *DSize; } - /**ptr1++ = (BYTE) NULL; /* Add NULL to simulate Terminator value */ +#ifdef COMMENTED_OUT + *ptr1++ = (BYTE) NULL; /* Add NULL to simulate Terminator value */ +#endif /* COMMENTED_OUT */ *ptr1++ = '\0'; return(ptr2); /* Return a pointer to the sub-block data */ diff --git a/hl/tools/gif2h5/hdf2gif.c b/hl/tools/gif2h5/hdf2gif.c index 9c4133e..39c75d1 100644 --- a/hl/tools/gif2h5/hdf2gif.c +++ b/hl/tools/gif2h5/hdf2gif.c @@ -19,16 +19,18 @@ extern int hdfWriteGIF(FILE *fp, BYTE *pic, int ptype, int w, int h, BYTE *rmap, int EndianOrder; -void PutByte(BYTE b , FILE *fpGif) +#ifdef NOT_USED +static void PutByte(BYTE b , FILE *fpGif) { if (fputc(b , fpGif) == EOF) { printf("File Writing Error, cannot continue"); exit(-1); } } +#endif /* NOT_USED */ -void putword(int w, FILE *fp) +static void putword(int w, FILE *fp) { /* writes a 16-bit integer in GIF order (LSB first) */ @@ -37,7 +39,8 @@ void putword(int w, FILE *fp) fputc((w>>8)&0xff,fp); } -void usage() { +static void usage(void ) +{ printf("Usage: h52gif <h5_file> <gif_file> -i <h5_image> [-p <h5_palette>]\n"); printf("h52gif expects *at least* one h5_image. You may repeat -i <h5_image> [-p <h5_palette>] at most 50 times (maximum of 50 images).\n"); } @@ -53,8 +56,6 @@ int main(int argc , char **argv) { CHAR *HDFName = NULL; CHAR *GIFName = NULL; - CHAR *image_path = NULL; - CHAR *pal_path = NULL; /* reference variables */ int has_local_palette; /* treated as a flag */ @@ -76,7 +77,7 @@ int main(int argc , char **argv) { int CountDown; int curx , cury; int time_out = 0; /* time between two images in the animation */ - int n_images , index; + int n_images , idx; BYTE pc2nc[256] , r1[256] , g1[256] , b1[256]; @@ -172,7 +173,7 @@ int main(int argc , char **argv) { n_images = number_of_images; Background = 0; - for (index = 0 ; index < n_images ; index++) { + for (idx = 0 ; idx < n_images ; idx++) { /* try to read the image and the palette */ /* Lots of funky stuff to support multiple images has been taken off. @@ -183,7 +184,7 @@ int main(int argc , char **argv) { ** to write the global palette out and then independantly write the smaller local ** palettes */ - if (ReadHDF(&Image , GlobalPalette , dim_sizes , HDFName , image_name_arr[index] , pal_name_arr[index]) < 0) { + if (ReadHDF(&Image , GlobalPalette , dim_sizes , HDFName , image_name_arr[idx] , pal_name_arr[idx]) < 0) { fprintf(stderr , "Unable to read HDF file\n"); return -1; } @@ -257,7 +258,7 @@ int main(int argc , char **argv) { /* If it is the first image we do all the header stuff that isn't required for the ** rest of the images. */ - if (index == 0) { + if (idx == 0) { /* Write out the GIF header and logical screen descriptor */ if (n_images > 1) { fwrite("GIF89a", 1, 6, fpGif); /* the GIF magic number */ @@ -331,7 +332,7 @@ int main(int argc , char **argv) { fputc (InitCodeSize , fpGif); - i = hdfWriteGIF(fpGif , Image , 0 , dim_sizes[0] , dim_sizes[1] , r1, g1 , b1 , pc2nc , 256 , 8 , BitsPerPixel); + i = hdfWriteGIF(fpGif , Image , 0 , (int)dim_sizes[0] , (int)dim_sizes[1] , r1, g1 , b1 , pc2nc , 256 , 8 , BitsPerPixel); fputc(0x00 , fpGif); free (Image); } diff --git a/hl/tools/gif2h5/hdfgifwr.c b/hl/tools/gif2h5/hdfgifwr.c index 28d556e..62b3eae 100644 --- a/hl/tools/gif2h5/hdfgifwr.c +++ b/hl/tools/gif2h5/hdfgifwr.c @@ -67,7 +67,6 @@ static long CountDown; static int Interlace; #ifdef __STDC__ -static void putword(int, FILE *); static void compress(int, FILE *, byte *, int); static void output(int); static void cl_block(void); @@ -76,27 +75,16 @@ static void char_init(void); static void char_out(int); static void flush_char(void); #else -static void putword(), compress(), output(), cl_block(), cl_hash(); +static void compress(), output(), cl_block(), cl_hash(); static void char_init(), char_out(), flush_char(); #endif static byte pc2nc[256],r1[256],g1[256],b1[256]; -void xvbzero(s, len) - char *s; - int len; -{ - for ( ; len>0; len--) *s++ = 0; -} - /*************************************************************/ -int hdfWriteGIF(fp, pic, ptype, w, h, rmap, gmap, bmap, pc2ncmap, numcols, colorstyle, BitsPerPixel) - FILE *fp; - byte *pic; - int ptype, w,h; - byte *rmap, *gmap, *bmap , *pc2ncmap; - int numcols, colorstyle; - int BitsPerPixel; +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) { int RWidth, RHeight; int LeftOfs, TopOfs; @@ -143,21 +131,6 @@ int hdfWriteGIF(fp, pic, ptype, w, h, rmap, gmap, bmap, pc2ncmap, numcols, colo -/******************************/ -static void putword(w, fp) -int w; -FILE *fp; -{ - /* writes a 16-bit integer in GIF order (LSB first) */ - - fputc(w &0xff, fp); - - fputc((w>>8)&0xff,fp); -} - - - - /***********************************************************************/ static unsigned long cur_accum = 0; static int cur_bits = 0; @@ -252,8 +225,8 @@ int len; /* initialize 'compress' globals */ maxbits = XV_BITS; maxmaxcode = 1<<XV_BITS; - xvbzero((char *) htab, sizeof(htab)); - xvbzero((char *) codetab, sizeof(codetab)); + memset(htab, 0, sizeof(htab)); + memset(codetab, 0, sizeof(codetab)); hsize = HSIZE; free_ent = 0; clear_flg = 0; @@ -375,7 +348,7 @@ int code; cur_bits += n_bits; while( cur_bits >= 8 ) { - char_out( (unsigned int) (cur_accum & 0xff) ); + char_out( (int)((unsigned int) cur_accum & 0xff) ); cur_accum >>= 8; cur_bits -= 8; } @@ -403,7 +376,7 @@ int code; if( code == EOFCode ) { /* At EOF, write the rest of the buffer */ while( cur_bits > 0 ) { - char_out( (unsigned int)(cur_accum & 0xff) ); + char_out( (int)((unsigned int)cur_accum & 0xff) ); cur_accum >>= 8; cur_bits -= 8; } @@ -434,14 +407,14 @@ static void cl_block () /* table clear for block compress */ /********************************/ -static void cl_hash(hsize) /* reset code table */ -register count_int hsize; +static void cl_hash(hashsize) /* reset code table */ +count_int hashsize; { - register count_int *htab_p = htab+hsize; - register long i; - register long m1 = -1; + count_int *htab_p = htab+hashsize; + long i; + long m1 = -1; - i = hsize - 16; + i = hashsize - 16; do { /* might use Sys V memset(3) here */ *(htab_p-16) = m1; *(htab_p-15) = m1; @@ -495,8 +468,7 @@ static char accum[ 256 ]; * Add a character to the end of the current packet, and if it is 254 * characters, flush the packet to disk. */ -static void char_out(c) -int c; +static void char_out(int c) { accum[ a_count++ ] = c; if( a_count >= 254 ) @@ -510,7 +482,7 @@ static void flush_char() { if( a_count > 0 ) { fputc( a_count, g_outfile ); - fwrite( accum, 1, a_count, g_outfile ); + fwrite( accum, 1, (size_t)a_count, g_outfile ); a_count = 0; } } diff --git a/hl/tools/gif2h5/readhdf.c b/hl/tools/gif2h5/readhdf.c index a7101c9..52a1837 100644 --- a/hl/tools/gif2h5/readhdf.c +++ b/hl/tools/gif2h5/readhdf.c @@ -35,14 +35,10 @@ int ReadHDF(BYTE** data , herr_t status; /* status variable */ hid_t dspace; /* dataspace identifier for the the dataset */ hid_t dset; /* dataset identifier */ - hid_t pal_set; /* dataset for palette */ hid_t pal_space;/* dataspace for palette */ - hsize_t pal_size; /* size of the palette */ - hsize_t datasize; /* size of the image */ hsize_t maxdims; /* dummy */ - int pal_exist = 0; /* do we have a palette? */ /* check stuff */ @@ -85,7 +81,7 @@ int ReadHDF(BYTE** data , datasize = image_size[0] * image_size[1]; /* allocate memory to store the image */ - if ((*data = (BYTE*) malloc(datasize)) == NULL) { + if ((*data = (BYTE*) malloc((size_t)datasize)) == NULL) { fprintf(stderr , "Out of memory, exiting"); return -1; } @@ -98,11 +94,8 @@ int ReadHDF(BYTE** data , } if (pal_exist) { - hsize_t pal_size[2]; - hsize_t max_pal_dims[2]; + hsize_t loc_pal_size[2]; hsize_t pal_datasize; - CHAR *pal_path; - BYTE *temp_buf; hsize_t temp_size; @@ -121,19 +114,19 @@ int ReadHDF(BYTE** data , } /* get the dimension size of the palette. */ - if (H5Sget_simple_extent_dims(pal_space , pal_size , &max_pal_dims) !=2 ) { + if (H5Sget_simple_extent_dims(pal_space , loc_pal_size , NULL) !=2 ) { fprintf(stderr , "Unable to get dimension info\n"); pal_exist = 0; return -1; } /* size needed to store the image */ - pal_datasize = pal_size[0] * pal_size[1]; + pal_datasize = loc_pal_size[0] * loc_pal_size[1]; /* copy stuff into a temp buffer and then copy 256*3 elements to palette */ temp_size = H5Dget_storage_size(pal_set); - temp_buf = (BYTE*) malloc (temp_size * sizeof(BYTE)); + temp_buf = (BYTE*) malloc ((size_t)temp_size * sizeof(BYTE)); /* make sure that the palette is actually 256 X 3 so that we don't create overflows */ if (pal_datasize > 256 * 3) @@ -152,7 +145,7 @@ int ReadHDF(BYTE** data , } /* copy stuff into the actual palette */ - memcpy(palette , temp_buf , pal_datasize); + memcpy(palette , temp_buf , (size_t)pal_datasize); /* get rid of the temp memory */ cleanup(temp_buf); diff --git a/hl/tools/gif2h5/writehdf.c b/hl/tools/gif2h5/writehdf.c index 7afccdf..5426c27 100644 --- a/hl/tools/gif2h5/writehdf.c +++ b/hl/tools/gif2h5/writehdf.c @@ -7,7 +7,8 @@ ** Function: write_text_attribute ** Use: Just a small wrapper to write text attributes easily ********************************************************************/ -int write_text_attribute(hid_t dataset_id , char *attr_name , char *attr_value) { +static int write_text_attribute(hid_t dataset_id , const char *attr_name , const char *attr_value) +{ /* variables for the attributes */ hsize_t attr_dims_size; /* dimensions for the attribute */ @@ -26,7 +27,7 @@ int write_text_attribute(hid_t dataset_id , char *attr_name , char *attr_value) /* set the type to string */ attr_type_id = H5Tcopy(H5T_C_S1); - H5Tset_size(attr_type_id , attr_dims_size); + H5Tset_size(attr_type_id , (size_t)attr_dims_size); /* create the dataspace for the attribute */ attr_dataspace_id = H5Screate_simple(1 , &attr_dims_size , NULL); @@ -59,18 +60,14 @@ char *HDFName; char *GIFFileName; { GIFHEAD gifHead; /* GIF Header structure */ - GIFIMAGEDESC* gifImageDesc; /* Logical Image Descriptor struct */ + GIFIMAGEDESC* gifImageDesc; /* Logical Image Descriptor struct */ long ImageCount , /* number of images */ CommentCount, /* number of comments */ ApplicationCount , /* number of application extensions */ PlainTextCount; /* number of plain text extensions */ - char ImageName[256], /* Image name for the GR Image */ - CommentName[256], - ApplicationName[256], - PlainTextName[256]; - + char ImageName[256]; /* Image name for the GR Image */ char GroupName[VSNAMELENMAX]; /* so that we can name the subgroups appropriately */ /* H5 variables */ @@ -82,11 +79,6 @@ char *GIFFileName; /* temp counter */ int i; - - - - - /* get the GIFMem stuff */ gifHead = *(GifMemoryStruct.GifHeader); @@ -36,9 +36,11 @@ #endif /* We need this on Irix64 even though we've included stdio.h as documented */ +#ifdef FIXME_ON_IRIX_THEN #if !defined __MWERKS__ FILE *fdopen(int fd, const char *mode); #endif +#endif /* FIXME_ON_IRIX_THEN */ #define PABLO_MASK H5_mask @@ -1295,16 +1295,16 @@ H5FD_alloc(H5FD_t *file, H5FD_mem_t type, hsize_t size) } #endif assert(tmp); /* bark in debug mode */ - if (tmp){ - if (tmp->size = (best->size - head - size)){ + if (tmp) { + if ((tmp->size = (best->size - head - size))) { tmp->addr = best->addr + head + size; tmp->next = best->next; best->next = tmp; - }else{ + } else { /* no tail piece */ H5MM_xfree(tmp); } - }else{ + } else { /* cannot keep the tail piece. leak file memory. */ } best->size = head; diff --git a/src/H5FDlog.c b/src/H5FDlog.c index ba16810..4c37651 100644 --- a/src/H5FDlog.c +++ b/src/H5FDlog.c @@ -986,7 +986,7 @@ H5FD_log_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, hadd while (size>0) { do { assert(size==(hsize_t)((size_t)size)); /*check for overflow*/ - nbytes = HDwrite(file->fd, (void*)buf, (size_t)size); + nbytes = HDwrite(file->fd, buf, (size_t)size); } while (-1==nbytes && EINTR==errno); if (-1==nbytes) { /* error */ diff --git a/src/H5FDstdio.c b/src/H5FDstdio.c index 6463fcb..b4da5ce 100644 --- a/src/H5FDstdio.c +++ b/src/H5FDstdio.c @@ -14,24 +14,23 @@ #include <stdlib.h> #include <sys/stat.h> +#include "hdf5.h" + #ifdef H5_HAVE_UNISTD_H #include <unistd.h> #endif - - -#include "hdf5.h" - #ifdef MAX #undef MAX #endif /* MAX */ #define MAX(X,Y) ((X)>(Y)?(X):(Y)) + #ifndef F_OK #define F_OK 00 #define W_OK 02 #define R_OK 04 - #endif + /* The driver identification number, initialized at runtime */ static hid_t H5FD_STDIO_g = 0; diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index 26412a7..e442b37 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -364,7 +364,7 @@ __DLL__ void * H5F_istore_chunk_free(void *chunk); __DLL__ void H5F_addr_encode(H5F_t *, uint8_t** /*in,out*/, haddr_t); __DLL__ void H5F_addr_decode(H5F_t *, const uint8_t** /*in,out*/, haddr_t* /*out*/); -__DLL__ herr_t H5F_addr_pack(H5F_t UNUSED *f, haddr_t *addr_p /*out*/, +__DLL__ herr_t H5F_addr_pack(H5F_t *f, haddr_t *addr_p /*out*/, const unsigned long objno[2]); #endif diff --git a/src/H5Sselect.c b/src/H5Sselect.c index c97d237..18c10e1 100644 --- a/src/H5Sselect.c +++ b/src/H5Sselect.c @@ -214,7 +214,7 @@ H5Sget_select_npoints(hid_t spaceid) PURPOSE Get the number of elements in current selection USAGE - herr_t H5Sselect_hyperslab(ds) + herr_t H5S_get_select_npoints(ds) H5S_t *ds; IN: Dataspace pointer RETURNS The number of elements in selection on success, 0 on failure diff --git a/src/H5Tprivate.h b/src/H5Tprivate.h index 079ea1e..28d505c 100644 --- a/src/H5Tprivate.h +++ b/src/H5Tprivate.h @@ -130,7 +130,7 @@ __DLL__ char *H5T_enum_nameof(H5T_t *dt, void *value, char *name/*out*/, size_t size); __DLL__ herr_t H5T_enum_valueof(H5T_t *dt, const char *name, void *value/*out*/); -__DLL__ herr_t H5T_vlen_reclaim(void *elem, hid_t type_id, hsize_t UNUSED ndim, hssize_t UNUSED *point, void UNUSED *_op_data); +__DLL__ herr_t H5T_vlen_reclaim(void *elem, hid_t type_id, hsize_t ndim, hssize_t *point, void *_op_data); __DLL__ htri_t H5T_vlen_mark(H5T_t *dt, H5F_t *f, H5T_vlen_loc_t loc); /* Reference specific functions */ diff --git a/src/H5private.h b/src/H5private.h index b9f1156..fcaf4c2 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -761,15 +761,11 @@ __DLL__ int64_t HDstrtoll (const char *s, const char **rest, int base); */ #ifdef WIN32 #define HDstrdup(S) _strdup(S) -#else +#else /* WIN32 */ -#ifdef LATER -#if !defined strdup && !defined HAVE_STRDUP +#if !defined strdup && !defined H5_HAVE_STRDUP extern char *strdup(const char *s); #endif -#else /* LATER */ -extern char *strdup(const char *s); -#endif /* LATER */ #define HDstrdup(S) strdup(S) diff --git a/test/dtypes.c b/test/dtypes.c index e461cf5..aa7d5cc 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -215,7 +215,7 @@ generates_sigfpe(void) for (i=0; i<2000; i++) { for (j=0; j<sizeof(double); j++) dp[j] = rand(); f = (float)d; - some_dummy_func(f); + some_dummy_func((float)f); } exit(0); } @@ -2896,12 +2896,12 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) break; case INT_LLONG: memcpy(aligned, saved+j*sizeof(long_long), sizeof(long_long)); - printf(" %29"PRINTF_LL_WIDTH"d\n", *((long_long*)aligned)); + HDfprintf(stdout," %29"PRINTF_LL_WIDTH"d\n", *((long_long*)aligned)); break; case INT_ULLONG: memcpy(aligned, saved+j*sizeof(long_long), sizeof(unsigned long_long)); - printf(" %29"PRINTF_LL_WIDTH"u\n", + HDfprintf(stdout," %29"PRINTF_LL_WIDTH"u\n", *((unsigned long_long*)aligned)); break; case INT_OTHER: @@ -2949,12 +2949,12 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) break; case INT_LLONG: memcpy(aligned, buf+j*sizeof(long_long), sizeof(long_long)); - printf(" %29"PRINTF_LL_WIDTH"d\n", *((long_long*)aligned)); + HDfprintf(stdout," %29"PRINTF_LL_WIDTH"d\n", *((long_long*)aligned)); break; case INT_ULLONG: memcpy(aligned, buf+j*sizeof(long_long), sizeof(unsigned long_long)); - printf(" %29"PRINTF_LL_WIDTH"u\n", + HDfprintf(stdout," %29"PRINTF_LL_WIDTH"u\n", *((unsigned long_long*)aligned)); break; case INT_OTHER: @@ -2993,10 +2993,10 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) printf(" %29lu\n", *((unsigned long*)hw)); break; case INT_LLONG: - printf(" %29"PRINTF_LL_WIDTH"d\n", *((long_long*)hw)); + HDfprintf(stdout," %29"PRINTF_LL_WIDTH"d\n", *((long_long*)hw)); break; case INT_ULLONG: - printf(" %29"PRINTF_LL_WIDTH"u\n", *((unsigned long_long*)hw)); + HDfprintf(stdout," %29"PRINTF_LL_WIDTH"u\n", *((unsigned long_long*)hw)); break; case INT_OTHER: break; @@ -3499,7 +3499,7 @@ test_conv_flt_1 (const char *name, hid_t src, hid_t dst) } else { long double x; memcpy(&x, (long double*)saved+j, sizeof(long double)); - printf(" %29.20Le\n", x); + HDfprintf(stdout," %29.20Le\n", x); #endif } @@ -3521,7 +3521,7 @@ test_conv_flt_1 (const char *name, hid_t src, hid_t dst) } else { long double x; memcpy(&x, (long double*)buf+j, sizeof(long double)); - printf(" %29.20Le\n", x); + HDfprintf(stdout," %29.20Le\n", x); #endif } @@ -3537,7 +3537,7 @@ test_conv_flt_1 (const char *name, hid_t src, hid_t dst) printf(" %29.20e\n", hw_d); #if SIZEOF_LONG_DOUBLE!=SIZEOF_DOUBLE } else { - printf(" %29.20Le\n", hw_ld); + HDfprintf(stdout," %29.20Le\n", hw_ld); #endif } diff --git a/test/h5test.c b/test/h5test.c index deca1fc..23a9ce2 100644 --- a/test/h5test.c +++ b/test/h5test.c @@ -11,6 +11,8 @@ #undef NDEBUG /*override -DNDEBUG */ #include "h5test.h" +#include <sys/types.h> +#include <sys/stat.h> #ifdef WIN32 #include <process.h> @@ -127,7 +129,7 @@ h5_cleanup(const char *base_name[], hid_t fapl) hid_t driver; #endif /* H5_WANT_H5_V1_2_COMPAT */ - if (!getenv("HDF5_NOCLEANUP")) { + if (!HDgetenv("HDF5_NOCLEANUP")) { for (i = 0; base_name[i]; i++) { if (h5_fixname(base_name[i], fapl, filename, sizeof(filename)) == NULL) continue; @@ -139,25 +141,25 @@ h5_cleanup(const char *base_name[], hid_t fapl) case H5F_LOW_SPLIT: HDsnprintf(temp, sizeof(temp), "%s.raw", filename); - remove(temp); + HDremove(temp); HDsnprintf(temp, sizeof(temp), "%s.meta", filename); - remove(temp); + HDremove(temp); break; case H5F_LOW_FAMILY: for (j = 0; /*void*/; j++) { HDsnprintf(temp, sizeof(temp), filename, j); - if (access(temp, F_OK) < 0) + if (HDaccess(temp, F_OK) < 0) break; - remove(temp); + HDremove(temp); } break; default: - remove(filename); + HDremove(filename); break; } #else /* H5_WANT_H5_V1_2_COMPAT */ @@ -168,10 +170,10 @@ h5_cleanup(const char *base_name[], hid_t fapl) for (j = 0; /*void*/; j++) { HDsnprintf(temp, sizeof temp, filename, j); - if (access(temp, F_OK) < 0) + if (HDaccess(temp, F_OK) < 0) break; - remove(temp); + HDremove(temp); } } else if (driver == H5FD_CORE) { /*void*/ @@ -182,10 +184,10 @@ h5_cleanup(const char *base_name[], hid_t fapl) for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt++) { HDsnprintf(temp, sizeof temp, "%s-%c.h5", filename, multi_letters[mt]); - remove(temp); /*don't care if it fails*/ + HDremove(temp); /*don't care if it fails*/ } } else { - remove(filename); + HDremove(filename); } #endif /* H5_WANT_H5_V1_2_COMPAT */ } @@ -217,8 +219,8 @@ h5_reset(void) { char filename[1024]; - fflush(stdout); - fflush(stderr); + HDfflush(stdout); + HDfflush(stderr); H5close(); H5Eset_auto (h5_errors, NULL); @@ -233,7 +235,7 @@ h5_reset(void) hid_t grp = H5Gcreate(file, "emit", 0); H5Gclose(grp); H5Fclose(file); - unlink(filename); + HDunlink(filename); } H5E_END_TRY; } @@ -313,7 +315,7 @@ h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size) /* For serial: * First use the environment variable, then try the constant */ - prefix = getenv("HDF5_PREFIX"); + prefix = HDgetenv("HDF5_PREFIX"); #ifdef HDF5_PREFIX if (!prefix) @@ -348,7 +350,7 @@ h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size) /* For serial: * First use the environment variable, then try the constant */ - prefix = getenv("HDF5_PREFIX"); + prefix = HDgetenv("HDF5_PREFIX"); #ifdef HDF5_PREFIX if (!prefix) @@ -367,14 +369,14 @@ h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size) /* This is a parallel system */ char *subdir; - if (!strcmp(prefix, HDF5_PARAPREFIX)) { + if (!HDstrcmp(prefix, HDF5_PARAPREFIX)) { /* If the prefix specifies the HDF5_PARAPREFIX directory, then * default to using the "/tmp/$USER" or "/tmp/$LOGIN" * directory instead. */ char *user, *login; - user = getenv("USER"); - login = getenv("LOGIN"); + user = HDgetenv("USER"); + login = HDgetenv("LOGIN"); subdir = (user ? user : login); if (subdir) { @@ -390,22 +392,22 @@ h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size) if (!fullname[0]) /* We didn't append the prefix yet */ - strncpy(fullname, prefix, MIN(strlen(prefix), size)); + HDstrncpy(fullname, prefix, MIN(strlen(prefix), size)); - if (strlen(fullname) + strlen(base_name) + 1 < size) { + if (HDstrlen(fullname) + HDstrlen(base_name) + 1 < size) { /* Append the base_name with a slash first. Multiple slashes are * handled below. */ struct stat buf; - if (stat(fullname, &buf) < 0) + if (HDstat(fullname, &buf) < 0) /* The directory doesn't exist just yet */ - if (mkdir(fullname, 0755) < 0 && errno != EEXIST) + if (HDmkdir(fullname, (mode_t)0755) < 0 && errno != EEXIST) /* We couldn't make the "/tmp/${USER,LOGIN}" subdirectory. * Default to PREFIX's original prefix value. */ - strcpy(fullname, prefix); + HDstrcpy(fullname, prefix); - strcat(fullname, "/"); - strcat(fullname, base_name); + HDstrcat(fullname, "/"); + HDstrcat(fullname, base_name); } else { /* Buffer is too small */ return NULL; @@ -415,11 +417,11 @@ h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size) /* Buffer is too small */ return NULL; } - } else if (strlen(base_name) >= size) { + } else if (HDstrlen(base_name) >= size) { /* Buffer is too small */ return NULL; } else { - strcpy(fullname, base_name); + HDstrcpy(fullname, base_name); } #ifdef H5_WANT_H5_V1_2_COMPAT @@ -428,25 +430,25 @@ h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size) return NULL; switch (driver) { - case H5F_LOW_SPLIT: - case H5F_LOW_CORE: - suffix = NULL; - break; - case H5F_LOW_FAMILY: - suffix = "%05d.h5"; - break; - default: - suffix = ".h5"; - break; + case H5F_LOW_SPLIT: + case H5F_LOW_CORE: + suffix = NULL; + break; + case H5F_LOW_FAMILY: + suffix = "%05d.h5"; + break; + default: + suffix = ".h5"; + break; } #endif /* H5_WANT_H5_V1_2_COMPAT */ /* Append a suffix */ if (suffix) { - if (strlen(fullname) + strlen(suffix) >= size) + if (HDstrlen(fullname) + HDstrlen(suffix) >= size) return NULL; - strcat(fullname, suffix); + HDstrcat(fullname, suffix); } /* Remove any double slashes in the filename */ @@ -491,7 +493,7 @@ h5_fileaccess(void) H5FD_mem_t mt; /* First use the environment variable, then the constant */ - val = getenv("HDF5_DRIVER"); + val = HDgetenv("HDF5_DRIVER"); #ifdef HDF5_DRIVER if (!val) val = HDF5_DRIVER; #endif @@ -499,26 +501,26 @@ h5_fileaccess(void) if ((fapl=H5Pcreate(H5P_FILE_ACCESS))<0) return -1; if (!val || !*val) return fapl; /*use default*/ - strncpy(s, val, sizeof s); + HDstrncpy(s, val, sizeof s); s[sizeof(s)-1] = '\0'; - if (NULL==(name=strtok(s, " \t\n\r"))) return fapl; + if (NULL==(name=HDstrtok(s, " \t\n\r"))) return fapl; - if (!strcmp(name, "sec2")) { + if (!HDstrcmp(name, "sec2")) { /* Unix read() and write() system calls */ if (H5Pset_fapl_sec2(fapl)<0) return -1; - } else if (!strcmp(name, "stdio")) { + } else if (!HDstrcmp(name, "stdio")) { /* Standard C fread() and fwrite() system calls */ if (H5Pset_fapl_stdio(fapl)<0) return -1; - } else if (!strcmp(name, "core")) { + } else if (!HDstrcmp(name, "core")) { /* In-core temporary file with 1MB increment */ if (H5Pset_fapl_core(fapl, 1024*1024, FALSE)<0) return -1; - } else if (!strcmp(name, "split")) { + } else if (!HDstrcmp(name, "split")) { /* Split meta data and raw data each using default driver */ if (H5Pset_fapl_split(fapl, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT)<0) return -1; - } else if (!strcmp(name, "multi")) { + } else if (!HDstrcmp(name, "multi")) { /* Multi-file driver, general case of the split driver */ H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; hid_t memb_fapl[H5FD_MEM_NTYPES]; @@ -526,12 +528,12 @@ h5_fileaccess(void) char sv[H5FD_MEM_NTYPES][1024]; haddr_t memb_addr[H5FD_MEM_NTYPES]; - memset(memb_map, 0, sizeof memb_map); - memset(memb_fapl, 0, sizeof memb_fapl); - memset(memb_name, 0, sizeof memb_name); - memset(memb_addr, 0, sizeof memb_addr); + HDmemset(memb_map, 0, sizeof memb_map); + HDmemset(memb_fapl, 0, sizeof memb_fapl); + HDmemset(memb_name, 0, sizeof memb_name); + HDmemset(memb_addr, 0, sizeof memb_addr); - assert(strlen(multi_letters)==H5FD_MEM_NTYPES); + assert(HDstrlen(multi_letters)==H5FD_MEM_NTYPES); for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; mt++) { memb_fapl[mt] = H5P_DEFAULT; sprintf(sv[mt], "%%s-%c.h5", multi_letters[mt]); @@ -543,16 +545,16 @@ h5_fileaccess(void) memb_addr, FALSE)<0) { return -1; } - } else if (!strcmp(name, "family")) { + } else if (!HDstrcmp(name, "family")) { /* Family of files, each 1MB and using the default driver */ - if ((val=strtok(NULL, " \t\n\r"))) { - fam_size = strtod(val, NULL) * 1024*1024; + if ((val=HDstrtok(NULL, " \t\n\r"))) { + fam_size = HDstrtod(val, NULL) * 1024*1024; } if (H5Pset_fapl_family(fapl, fam_size, H5P_DEFAULT)<0) return -1; - } else if (!strcmp(name, "log")) { + } else if (!HDstrcmp(name, "log")) { /* Log file access */ - if ((val = strtok(NULL, " \t\n\r"))) - verbosity = strtol(val, NULL, 0); + if ((val = HDstrtok(NULL, " \t\n\r"))) + verbosity = HDstrtol(val, NULL, 0); if (H5Pset_fapl_log(fapl, NULL, (int)verbosity) < 0) return -1; diff --git a/test/tselect.c b/test/tselect.c index 4aea1cb..b140d16 100644 --- a/test/tselect.c +++ b/test/tselect.c @@ -567,12 +567,8 @@ test_select_all(hid_t xfer_plist) { hid_t fid1; /* HDF5 File IDs */ hid_t dataset; /* Dataset ID */ - hid_t sid1,sid2; /* Dataspace ID */ + hid_t sid1; /* Dataspace ID */ hsize_t dims1[] = {SPACE4_DIM1, SPACE4_DIM2, SPACE4_DIM3}; - hssize_t start[SPACE4_RANK]; /* Starting location of hyperslab */ - hsize_t stride[SPACE4_RANK]; /* Stride of hyperslab */ - hsize_t count[SPACE4_RANK]; /* Element count of hyperslab */ - hsize_t block[SPACE4_RANK]; /* Block size of hyperslab */ uint8_t *wbuf, /* buffer to write to disk */ *rbuf, /* buffer read from disk */ *tbuf; /* temporary buffer pointer */ diff --git a/test/tvltypes.c b/test/tvltypes.c index 3dc4b3f..8fb6b9a 100644 --- a/test/tvltypes.c +++ b/test/tvltypes.c @@ -51,7 +51,7 @@ void test_vltypes_free_custom(void *mem, void *info); void *test_vltypes_alloc_custom(size_t size, void *info) { void *ret_value=NULL; /* Pointer to return */ - int *mem_used=(int *)info; /* Get the pointer to the memory used */ + size_t *mem_used=(size_t *)info; /* Get the pointer to the memory used */ size_t extra; /* Extra space needed */ /* @@ -79,7 +79,7 @@ void *test_vltypes_alloc_custom(size_t size, void *info) void test_vltypes_free_custom(void *_mem, void *info) { unsigned char *mem; - int *mem_used=(int *)info; /* Get the pointer to the memory used */ + size_t *mem_used=(size_t *)info; /* Get the pointer to the memory used */ size_t extra; /* Extra space needed */ /* @@ -114,7 +114,7 @@ test_vltypes_vlen_atomic(void) hsize_t dims1[] = {SPACE1_DIM1}; hsize_t size; /* Number of bytes which will be used */ uintn i,j; /* counting variables */ - int mem_used=0; /* Memory used during allocation */ + size_t mem_used=0; /* Memory used during allocation */ herr_t ret; /* Generic return value */ /* Output message about test being performed */ @@ -242,7 +242,7 @@ test_vltypes_vlen_compound(void) hsize_t dims1[] = {SPACE1_DIM1}; hsize_t size; /* Number of bytes which will be used */ uintn i,j; /* counting variables */ - int mem_used=0; /* Memory used during allocation */ + size_t mem_used=0; /* Memory used during allocation */ herr_t ret; /* Generic return value */ /* Output message about test being performed */ @@ -392,7 +392,7 @@ test_vltypes_compound_vlen_atomic(void) hsize_t dims1[] = {SPACE1_DIM1}; hsize_t size; /* Number of bytes which will be used */ uintn i,j; /* counting variables */ - int mem_used=0; /* Memory used during allocation */ + size_t mem_used=0; /* Memory used during allocation */ herr_t ret; /* Generic return value */ /* Output message about test being performed */ @@ -531,11 +531,11 @@ test_vltypes_compound_vlen_atomic(void) ** Tests VL datatype with VL datatypes of atomic datatypes. ** ****************************************************************/ -static unsigned long vlen_size_func(unsigned long n) +static size_t vlen_size_func(unsigned long n) { - unsigned long u=1; - unsigned long tmp=1; - unsigned long result=1; + size_t u=1; + size_t tmp=1; + size_t result=1; while(u<n) { u++; @@ -565,7 +565,7 @@ test_vltypes_vlen_vlen_atomic(void) hsize_t dims1[] = {SPACE1_DIM1}; hsize_t size; /* Number of bytes which will be used */ uintn i,j,k; /* counting variables */ - int mem_used=0; /* Memory used during allocation */ + size_t mem_used=0; /* Memory used during allocation */ herr_t ret; /* Generic return value */ /* Output message about test being performed */ diff --git a/tools/gifconv/decompress.c b/tools/gifconv/decompress.c index 18dbb3e..abccb7f 100644 --- a/tools/gifconv/decompress.c +++ b/tools/gifconv/decompress.c @@ -19,13 +19,8 @@ static int BitOffset = 0, /* Bit Offset of next code */ XC = 0, YC = 0, /* Output X and Y coords of current pixel */ Pass = 0, /* Used by output routine if WORDerlaced pic */ OutCount = 0, /* Decompressor output 'stack count' */ -RWidth, RHeight, /* screen dimensions */ IWidth, IHeight, /* image dimensions */ -LeftOfs, TopOfs, /* image offset */ -BitsPerPixel, /* Bits per pixel, read from GIF header */ BytesPerScanline, /* Bytes per scanline in output raster */ -ColorMapSize, /* number of colors */ -Background, /* background color */ CodeSize, /* Code size, read from GIF header */ InitCodeSize, /* Starting code size, used during Clear */ Code, /* Value returned by ReadCode */ @@ -73,7 +68,7 @@ int numused; * three BYTEs, compute the bit Offset WORDo our 24-bit chunk, shift to * bring the desired code to the bottom, then mask it off and return it. */ -ReadCode() +static int ReadCode(void) { int RawCode, ByteOffset; @@ -87,8 +82,7 @@ ReadCode() } -AddToPixel(Index) -BYTE Index; +static void AddToPixel(BYTE Index) { if (YC<IHeight) *(Image + YC * BytesPerScanline + XC) = Index; @@ -202,7 +196,7 @@ GIFHEAD *GifHead; /* Allocate the Image */ - if (!(Image = (BYTE *)malloc(IWidth*IHeight))) { + if (!(Image = (BYTE *)malloc((size_t)IWidth*(size_t)IHeight))) { printf("Out of memory"); exit(-1); } diff --git a/tools/gifconv/gif.h b/tools/gifconv/gif.h index f697881..3f2a8da 100644 --- a/tools/gifconv/gif.h +++ b/tools/gifconv/gif.h @@ -169,7 +169,6 @@ int WriteHDF(GIFTOMEM , CHAR * , CHAR *); */ int ReadHDF(BYTE** data , BYTE palette[256][3] , hsize_t *image_size , CHAR *h5_file , CHAR *dset_name , CHAR *pal_name); -BYTE *ReadDataSubBlocks(BYTE ** , WORD *); BYTE *Decompress (GIFIMAGEDESC * , GIFHEAD *); BYTE GetByte(BYTE *); WORD GetWord(BYTE *); diff --git a/tools/gifconv/gif2hdf.c b/tools/gifconv/gif2hdf.c index 0211143..6b4ae2b 100644 --- a/tools/gifconv/gif2hdf.c +++ b/tools/gifconv/gif2hdf.c @@ -3,10 +3,9 @@ #include <string.h> #include <stdio.h> #include <stdlib.h> + int -main(argv , argc) -int argv; -char *argc[]; +main(int argv , char *argc[]) { GIFTOMEM GifMemoryStruct; @@ -60,11 +59,11 @@ char *argc[]; filesize = ftell(fpGif); fseek(fpGif, 0L , 0); if (filesize == 0) printf("File Size Zero"); - if (!(MemGif = StartPos = (BYTE *)malloc(filesize))) { + if (!(MemGif = StartPos = (BYTE *)malloc((size_t)filesize))) { printf("Out of memory"); exit (-1); } - if (fread(MemGif,filesize,1,fpGif) != 1) { + if (fread(MemGif,(size_t)filesize,1,fpGif) != 1) { printf("Corrupted Input File"); exit(-1); } diff --git a/tools/gifconv/gif2mem.c b/tools/gifconv/gif2mem.c index 92ca8e5..830eba7 100644 --- a/tools/gifconv/gif2mem.c +++ b/tools/gifconv/gif2mem.c @@ -25,7 +25,6 @@ /* #include <hdf.h> */ #define VERSION "1.00" -extern int EndianOrder; GIFTOMEM Gif2Mem(MemGif) diff --git a/tools/gifconv/gifread.c b/tools/gifconv/gifread.c index 1196241..cb033d9 100644 --- a/tools/gifconv/gifread.c +++ b/tools/gifconv/gifread.c @@ -3,14 +3,14 @@ #include "gif.h" int EndianOrder; -int i; +static BYTE * ReadDataSubBlocks(BYTE **MemGif2, WORD *DSize); WORD GetWord (MemGif) BYTE *MemGif; { - register WORD w; + WORD w; if (EndianOrder == 1) /* LittleEndian */ { w = (WORD) (*MemGif++ & 0xFF); @@ -46,14 +46,14 @@ ReadGifHeader(GifHead, MemGif2) GIFHEAD *GifHead; /* Pointer to GIF header structure */ BYTE **MemGif2; /* GIF image file input FILE stream */ { - register WORD i; /* Loop counter */ + WORD i; /* Loop counter */ WORD tableSize; /* Number of entires in the Global Color Table */ GifHead->TableSize = 0; for (i = 0 ; i < 6 ; i++) { GifHead->HeaderDump[i] = *(*MemGif2)++; } - if (strncmp(GifHead->HeaderDump , "GIF" , 3)) { + if (strncmp((const char *)GifHead->HeaderDump , "GIF" , 3)) { printf("The file does not appear to be a valid GIF file.\n"); exit(-1); } @@ -114,9 +114,9 @@ ReadGifImageDesc(GifImageDesc, MemGif2) GIFIMAGEDESC *GifImageDesc; /* Pointer to GIF image descriptor structure */ BYTE **MemGif2; /* GIF image file input FILE stream */ { - register WORD i; /* Loop counter */ + WORD i; /* Loop counter */ WORD tableSize; /* Number of entries in the Local Color Table */ - BYTE Interlace; /* PackedField & 0x20 gives information on interlacing */ + /* BYTE Interlace; */ /* PackedField & 0x20 gives information on interlacing */ BYTE *TempPtr; int ch , ch1; @@ -210,11 +210,11 @@ ReadGifGraphicControl(GifGraphicControl, MemGif2) GIFGRAPHICCONTROL *GifGraphicControl; /* Pointer to GC Extension structure */ BYTE **MemGif2; /* GIF image file input FILE stream */ { + int i; - - for (i = 0 ; i < 5 ; i++) { - GifGraphicControl->GCEDump[i] = *(*MemGif2)++; - } + for (i = 0 ; i < 5 ; i++) { + GifGraphicControl->GCEDump[i] = *(*MemGif2)++; + } return(0); /* No FILE stream error occured */ } @@ -234,6 +234,8 @@ ReadGifPlainText(GifPlainText, MemGif2) GIFPLAINTEXT *GifPlainText; /* Pointer to Plain Text Extension structure */ BYTE **MemGif2; /* GIF image file input FILE stream */ { + int i; + for (i = 0 ; i < 13 ; i++) { GifPlainText->PTEDump[i] = *(*MemGif2)++; } @@ -270,6 +272,8 @@ ReadGifApplication(GifApplication, MemGif2) GIFAPPLICATION *GifApplication; /* Pointer to Application Extension structure */ BYTE **MemGif2; /* GIF image file input FILE stream */ { + int i; + for (i = 0 ; i < 12 ; i++) { GifApplication->AEDump[i] = *(*MemGif2)++; } @@ -327,9 +331,8 @@ BYTE **MemGif2; /* GIF image file input FILE stream */ ** otherwise a valid pointer if no error occured. */ static BYTE * -ReadDataSubBlocks(MemGif2 , DSize) -BYTE **MemGif2; /* GIF image file input FILE stream */ -WORD *DSize; +ReadDataSubBlocks(BYTE **MemGif2, /* GIF image file input FILE stream */ + WORD *DSize) { BYTE *ptr1; /* Pointer used to "walk the heap" */ BYTE *ptr2; /* Pointer used to mark the top of the heap */ @@ -342,7 +345,7 @@ WORD *DSize; dataSize = *(*MemGif2)++; /* Get the size of the first sub-block */ /* Allocate initial data buffer */ - if (!(ptr1 = ptr2 = (BYTE *) malloc(dataSize + 1))) { + if (!(ptr1 = ptr2 = (BYTE *) malloc((size_t)dataSize + 1))) { printf("Out of memory. Allocation of memory for data sub-blocks for\neither Comment, Plain Text or Application Extensions failed"); return((BYTE *) NULL); } @@ -352,7 +355,9 @@ WORD *DSize; bufSize += (dataSize); /* Running total of the buffer size */ *DSize = bufSize; - /* *ptr1++ = dataSize; /* Write the data count */ +#ifdef COMMENTED_OUT + *ptr1++ = dataSize; /* Write the data count */ +#endif /* COMMENTED_OUT */ while (dataSize--) /* Read/write the Plain Text data */ *ptr1++ = *(*MemGif2)++; @@ -370,7 +375,9 @@ WORD *DSize; } - /**ptr1++ = (BYTE) NULL; /* Add NULL to simulate Terminator value */ +#ifdef COMMENTED_OUT + *ptr1++ = (BYTE) NULL; /* Add NULL to simulate Terminator value */ +#endif /* COMMENTED_OUT */ *ptr1++ = '\0'; return(ptr2); /* Return a pointer to the sub-block data */ diff --git a/tools/gifconv/hdf2gif.c b/tools/gifconv/hdf2gif.c index 9c4133e..39c75d1 100644 --- a/tools/gifconv/hdf2gif.c +++ b/tools/gifconv/hdf2gif.c @@ -19,16 +19,18 @@ extern int hdfWriteGIF(FILE *fp, BYTE *pic, int ptype, int w, int h, BYTE *rmap, int EndianOrder; -void PutByte(BYTE b , FILE *fpGif) +#ifdef NOT_USED +static void PutByte(BYTE b , FILE *fpGif) { if (fputc(b , fpGif) == EOF) { printf("File Writing Error, cannot continue"); exit(-1); } } +#endif /* NOT_USED */ -void putword(int w, FILE *fp) +static void putword(int w, FILE *fp) { /* writes a 16-bit integer in GIF order (LSB first) */ @@ -37,7 +39,8 @@ void putword(int w, FILE *fp) fputc((w>>8)&0xff,fp); } -void usage() { +static void usage(void ) +{ printf("Usage: h52gif <h5_file> <gif_file> -i <h5_image> [-p <h5_palette>]\n"); printf("h52gif expects *at least* one h5_image. You may repeat -i <h5_image> [-p <h5_palette>] at most 50 times (maximum of 50 images).\n"); } @@ -53,8 +56,6 @@ int main(int argc , char **argv) { CHAR *HDFName = NULL; CHAR *GIFName = NULL; - CHAR *image_path = NULL; - CHAR *pal_path = NULL; /* reference variables */ int has_local_palette; /* treated as a flag */ @@ -76,7 +77,7 @@ int main(int argc , char **argv) { int CountDown; int curx , cury; int time_out = 0; /* time between two images in the animation */ - int n_images , index; + int n_images , idx; BYTE pc2nc[256] , r1[256] , g1[256] , b1[256]; @@ -172,7 +173,7 @@ int main(int argc , char **argv) { n_images = number_of_images; Background = 0; - for (index = 0 ; index < n_images ; index++) { + for (idx = 0 ; idx < n_images ; idx++) { /* try to read the image and the palette */ /* Lots of funky stuff to support multiple images has been taken off. @@ -183,7 +184,7 @@ int main(int argc , char **argv) { ** to write the global palette out and then independantly write the smaller local ** palettes */ - if (ReadHDF(&Image , GlobalPalette , dim_sizes , HDFName , image_name_arr[index] , pal_name_arr[index]) < 0) { + if (ReadHDF(&Image , GlobalPalette , dim_sizes , HDFName , image_name_arr[idx] , pal_name_arr[idx]) < 0) { fprintf(stderr , "Unable to read HDF file\n"); return -1; } @@ -257,7 +258,7 @@ int main(int argc , char **argv) { /* If it is the first image we do all the header stuff that isn't required for the ** rest of the images. */ - if (index == 0) { + if (idx == 0) { /* Write out the GIF header and logical screen descriptor */ if (n_images > 1) { fwrite("GIF89a", 1, 6, fpGif); /* the GIF magic number */ @@ -331,7 +332,7 @@ int main(int argc , char **argv) { fputc (InitCodeSize , fpGif); - i = hdfWriteGIF(fpGif , Image , 0 , dim_sizes[0] , dim_sizes[1] , r1, g1 , b1 , pc2nc , 256 , 8 , BitsPerPixel); + i = hdfWriteGIF(fpGif , Image , 0 , (int)dim_sizes[0] , (int)dim_sizes[1] , r1, g1 , b1 , pc2nc , 256 , 8 , BitsPerPixel); fputc(0x00 , fpGif); free (Image); } diff --git a/tools/gifconv/hdfgifwr.c b/tools/gifconv/hdfgifwr.c index 28d556e..62b3eae 100644 --- a/tools/gifconv/hdfgifwr.c +++ b/tools/gifconv/hdfgifwr.c @@ -67,7 +67,6 @@ static long CountDown; static int Interlace; #ifdef __STDC__ -static void putword(int, FILE *); static void compress(int, FILE *, byte *, int); static void output(int); static void cl_block(void); @@ -76,27 +75,16 @@ static void char_init(void); static void char_out(int); static void flush_char(void); #else -static void putword(), compress(), output(), cl_block(), cl_hash(); +static void compress(), output(), cl_block(), cl_hash(); static void char_init(), char_out(), flush_char(); #endif static byte pc2nc[256],r1[256],g1[256],b1[256]; -void xvbzero(s, len) - char *s; - int len; -{ - for ( ; len>0; len--) *s++ = 0; -} - /*************************************************************/ -int hdfWriteGIF(fp, pic, ptype, w, h, rmap, gmap, bmap, pc2ncmap, numcols, colorstyle, BitsPerPixel) - FILE *fp; - byte *pic; - int ptype, w,h; - byte *rmap, *gmap, *bmap , *pc2ncmap; - int numcols, colorstyle; - int BitsPerPixel; +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) { int RWidth, RHeight; int LeftOfs, TopOfs; @@ -143,21 +131,6 @@ int hdfWriteGIF(fp, pic, ptype, w, h, rmap, gmap, bmap, pc2ncmap, numcols, colo -/******************************/ -static void putword(w, fp) -int w; -FILE *fp; -{ - /* writes a 16-bit integer in GIF order (LSB first) */ - - fputc(w &0xff, fp); - - fputc((w>>8)&0xff,fp); -} - - - - /***********************************************************************/ static unsigned long cur_accum = 0; static int cur_bits = 0; @@ -252,8 +225,8 @@ int len; /* initialize 'compress' globals */ maxbits = XV_BITS; maxmaxcode = 1<<XV_BITS; - xvbzero((char *) htab, sizeof(htab)); - xvbzero((char *) codetab, sizeof(codetab)); + memset(htab, 0, sizeof(htab)); + memset(codetab, 0, sizeof(codetab)); hsize = HSIZE; free_ent = 0; clear_flg = 0; @@ -375,7 +348,7 @@ int code; cur_bits += n_bits; while( cur_bits >= 8 ) { - char_out( (unsigned int) (cur_accum & 0xff) ); + char_out( (int)((unsigned int) cur_accum & 0xff) ); cur_accum >>= 8; cur_bits -= 8; } @@ -403,7 +376,7 @@ int code; if( code == EOFCode ) { /* At EOF, write the rest of the buffer */ while( cur_bits > 0 ) { - char_out( (unsigned int)(cur_accum & 0xff) ); + char_out( (int)((unsigned int)cur_accum & 0xff) ); cur_accum >>= 8; cur_bits -= 8; } @@ -434,14 +407,14 @@ static void cl_block () /* table clear for block compress */ /********************************/ -static void cl_hash(hsize) /* reset code table */ -register count_int hsize; +static void cl_hash(hashsize) /* reset code table */ +count_int hashsize; { - register count_int *htab_p = htab+hsize; - register long i; - register long m1 = -1; + count_int *htab_p = htab+hashsize; + long i; + long m1 = -1; - i = hsize - 16; + i = hashsize - 16; do { /* might use Sys V memset(3) here */ *(htab_p-16) = m1; *(htab_p-15) = m1; @@ -495,8 +468,7 @@ static char accum[ 256 ]; * Add a character to the end of the current packet, and if it is 254 * characters, flush the packet to disk. */ -static void char_out(c) -int c; +static void char_out(int c) { accum[ a_count++ ] = c; if( a_count >= 254 ) @@ -510,7 +482,7 @@ static void flush_char() { if( a_count > 0 ) { fputc( a_count, g_outfile ); - fwrite( accum, 1, a_count, g_outfile ); + fwrite( accum, 1, (size_t)a_count, g_outfile ); a_count = 0; } } diff --git a/tools/gifconv/readhdf.c b/tools/gifconv/readhdf.c index a7101c9..52a1837 100644 --- a/tools/gifconv/readhdf.c +++ b/tools/gifconv/readhdf.c @@ -35,14 +35,10 @@ int ReadHDF(BYTE** data , herr_t status; /* status variable */ hid_t dspace; /* dataspace identifier for the the dataset */ hid_t dset; /* dataset identifier */ - hid_t pal_set; /* dataset for palette */ hid_t pal_space;/* dataspace for palette */ - hsize_t pal_size; /* size of the palette */ - hsize_t datasize; /* size of the image */ hsize_t maxdims; /* dummy */ - int pal_exist = 0; /* do we have a palette? */ /* check stuff */ @@ -85,7 +81,7 @@ int ReadHDF(BYTE** data , datasize = image_size[0] * image_size[1]; /* allocate memory to store the image */ - if ((*data = (BYTE*) malloc(datasize)) == NULL) { + if ((*data = (BYTE*) malloc((size_t)datasize)) == NULL) { fprintf(stderr , "Out of memory, exiting"); return -1; } @@ -98,11 +94,8 @@ int ReadHDF(BYTE** data , } if (pal_exist) { - hsize_t pal_size[2]; - hsize_t max_pal_dims[2]; + hsize_t loc_pal_size[2]; hsize_t pal_datasize; - CHAR *pal_path; - BYTE *temp_buf; hsize_t temp_size; @@ -121,19 +114,19 @@ int ReadHDF(BYTE** data , } /* get the dimension size of the palette. */ - if (H5Sget_simple_extent_dims(pal_space , pal_size , &max_pal_dims) !=2 ) { + if (H5Sget_simple_extent_dims(pal_space , loc_pal_size , NULL) !=2 ) { fprintf(stderr , "Unable to get dimension info\n"); pal_exist = 0; return -1; } /* size needed to store the image */ - pal_datasize = pal_size[0] * pal_size[1]; + pal_datasize = loc_pal_size[0] * loc_pal_size[1]; /* copy stuff into a temp buffer and then copy 256*3 elements to palette */ temp_size = H5Dget_storage_size(pal_set); - temp_buf = (BYTE*) malloc (temp_size * sizeof(BYTE)); + temp_buf = (BYTE*) malloc ((size_t)temp_size * sizeof(BYTE)); /* make sure that the palette is actually 256 X 3 so that we don't create overflows */ if (pal_datasize > 256 * 3) @@ -152,7 +145,7 @@ int ReadHDF(BYTE** data , } /* copy stuff into the actual palette */ - memcpy(palette , temp_buf , pal_datasize); + memcpy(palette , temp_buf , (size_t)pal_datasize); /* get rid of the temp memory */ cleanup(temp_buf); diff --git a/tools/gifconv/writehdf.c b/tools/gifconv/writehdf.c index 7afccdf..5426c27 100644 --- a/tools/gifconv/writehdf.c +++ b/tools/gifconv/writehdf.c @@ -7,7 +7,8 @@ ** Function: write_text_attribute ** Use: Just a small wrapper to write text attributes easily ********************************************************************/ -int write_text_attribute(hid_t dataset_id , char *attr_name , char *attr_value) { +static int write_text_attribute(hid_t dataset_id , const char *attr_name , const char *attr_value) +{ /* variables for the attributes */ hsize_t attr_dims_size; /* dimensions for the attribute */ @@ -26,7 +27,7 @@ int write_text_attribute(hid_t dataset_id , char *attr_name , char *attr_value) /* set the type to string */ attr_type_id = H5Tcopy(H5T_C_S1); - H5Tset_size(attr_type_id , attr_dims_size); + H5Tset_size(attr_type_id , (size_t)attr_dims_size); /* create the dataspace for the attribute */ attr_dataspace_id = H5Screate_simple(1 , &attr_dims_size , NULL); @@ -59,18 +60,14 @@ char *HDFName; char *GIFFileName; { GIFHEAD gifHead; /* GIF Header structure */ - GIFIMAGEDESC* gifImageDesc; /* Logical Image Descriptor struct */ + GIFIMAGEDESC* gifImageDesc; /* Logical Image Descriptor struct */ long ImageCount , /* number of images */ CommentCount, /* number of comments */ ApplicationCount , /* number of application extensions */ PlainTextCount; /* number of plain text extensions */ - char ImageName[256], /* Image name for the GR Image */ - CommentName[256], - ApplicationName[256], - PlainTextName[256]; - + char ImageName[256]; /* Image name for the GR Image */ char GroupName[VSNAMELENMAX]; /* so that we can name the subgroups appropriately */ /* H5 variables */ @@ -82,11 +79,6 @@ char *GIFFileName; /* temp counter */ int i; - - - - - /* get the GIFMem stuff */ gifHead = *(GifMemoryStruct.GifHeader); diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c index 5eb2a7f..3e8b396 100644 --- a/tools/h5dump/h5dump.c +++ b/tools/h5dump/h5dump.c @@ -1745,7 +1745,7 @@ dump_subsetting_header(struct subset_t *sset, int dims) indentation(indent); printf("%s %s ", dump_header_format->startbegin, dump_header_format->startblockbegin); - dump_dims(sset->start, dims); + dump_dims((hsize_t *)sset->start, dims); printf("%s %s\n", dump_header_format->startend, dump_header_format->startblockend); @@ -2040,7 +2040,7 @@ parse_subset_params(char *dset) *brace++ = '\0'; s = calloc(1, sizeof(struct subset_t)); - s->start = parse_hsize_list(brace); + s->start = (hssize_t *)parse_hsize_list(brace); while (*brace && *brace != ';') brace++; @@ -2531,7 +2531,7 @@ parse_start: */ do { switch ((char)opt) { - case 's': free(s->start); s->start = parse_hsize_list(opt_arg); break; + case 's': free(s->start); s->start = (hssize_t *)parse_hsize_list(opt_arg); break; case 'S': free(s->stride); s->stride = parse_hsize_list(opt_arg); break; case 'c': free(s->count); s->count = parse_hsize_list(opt_arg); break; case 'k': free(s->block); s->block = parse_hsize_list(opt_arg); break; @@ -2902,10 +2902,10 @@ print_enum(hid_t type) for (j = 0; j < dst_size; j++) printf("%02x", value[i * dst_size + j]); } else if (H5T_SGN_NONE == H5Tget_sign(native)) { - printf("%" PRINTF_LL_WIDTH "u", *((unsigned long_long *) + HDfprintf(stdout,"%" PRINTF_LL_WIDTH "u", *((unsigned long_long *) ((void *) (value + i * dst_size)))); } else { - printf("%" PRINTF_LL_WIDTH "d", + HDfprintf(stdout,"%" PRINTF_LL_WIDTH "d", *((long_long *) ((void *) (value + i * dst_size)))); } @@ -4867,10 +4867,10 @@ xml_print_enum(hid_t type) for (j = 0; j < dst_size; j++) printf("%02x", value[i * dst_size + j]); } else if (H5T_SGN_NONE == H5Tget_sign(native)) { - printf("%" PRINTF_LL_WIDTH "u", *((unsigned long_long *) + HDfprintf(stdout,"%" PRINTF_LL_WIDTH "u", *((unsigned long_long *) ((void *) (value + i * dst_size)))); } else { - printf("%" PRINTF_LL_WIDTH "d", + HDfprintf(stdout,"%" PRINTF_LL_WIDTH "d", *((long_long *) ((void *) (value + i * dst_size)))); } printf("\n"); diff --git a/tools/h5dump/h5dumptst.c b/tools/h5dump/h5dumptst.c index bdb394b..b4ab79e 100644 --- a/tools/h5dump/h5dumptst.c +++ b/tools/h5dump/h5dumptst.c @@ -1667,15 +1667,15 @@ static void test_nestcomp(void) float b; double c; cmp_t d; - } s1_t; + } s2_t; hid_t cmp_tid; /* Handle for the compound datatype */ hid_t char_id; /* Handle for the string datatype */ hid_t array_dt; hsize_t array_dims[] = {2}; /* Dataspace dimensions */ int ndims = 1; /* Number of dimensions in the array field */ - s1_t s1[10]; - hid_t s1_tid; /* File datatype identifier */ + s2_t s1[10]; + hid_t s2_tid; /* File datatype identifier */ int i; hid_t file, dataset, space; /* Handles */ @@ -1724,30 +1724,30 @@ static void test_nestcomp(void) H5Tinsert(cmp_tid, "array_name", HOFFSET(cmp_t, b), array_dt); H5Tclose(array_dt); - s1_tid = H5Tcreate (H5T_COMPOUND, sizeof(s1_t)); - H5Tinsert(s1_tid, "a_name", HOFFSET(s1_t, a), H5T_NATIVE_INT); - H5Tinsert(s1_tid, "c_name", HOFFSET(s1_t, c), H5T_NATIVE_DOUBLE); - H5Tinsert(s1_tid, "b_name", HOFFSET(s1_t, b), H5T_NATIVE_FLOAT); + s2_tid = H5Tcreate (H5T_COMPOUND, sizeof(s2_t)); + H5Tinsert(s2_tid, "a_name", HOFFSET(s2_t, a), H5T_NATIVE_INT); + H5Tinsert(s2_tid, "c_name", HOFFSET(s2_t, c), H5T_NATIVE_DOUBLE); + H5Tinsert(s2_tid, "b_name", HOFFSET(s2_t, b), H5T_NATIVE_FLOAT); /* Insert compound memeber created above */ - H5Tinsert(s1_tid, "d_name", HOFFSET(s1_t, d), cmp_tid); + H5Tinsert(s2_tid, "d_name", HOFFSET(s2_t, d), cmp_tid); /* * Create the dataset. */ - dataset = H5Dcreate(file, datasetname, s1_tid, space, H5P_DEFAULT); + dataset = H5Dcreate(file, datasetname, s2_tid, space, H5P_DEFAULT); /* * Wtite data to the dataset; */ - status = H5Dwrite(dataset, s1_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, s1); + status = H5Dwrite(dataset, s2_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, s1); if (status < 0) fprintf(stderr, "test_nestcomp H5Dwrite failed\n"); /* * Release resources */ - H5Tclose(s1_tid); + H5Tclose(s2_tid); H5Tclose(cmp_tid); H5Tclose(char_id); H5Sclose(space); @@ -2241,8 +2241,8 @@ static void test_array4(void) typedef struct { /* Typedef for compound datatype */ int i; float f; - } s1_t; - s1_t wdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information to write */ + } s2_t; + s2_t wdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information to write */ hid_t fid1; /* HDF5 File IDs */ hid_t dataset; /* Dataset ID */ hid_t sid1; /* Dataspace ID */ @@ -2267,13 +2267,13 @@ static void test_array4(void) sid1 = H5Screate_simple(SPACE1_RANK, sdims1, NULL); /* Create a compound datatype to refer to */ - tid2 = H5Tcreate(H5T_COMPOUND, sizeof(s1_t)); + tid2 = H5Tcreate(H5T_COMPOUND, sizeof(s2_t)); /* Insert integer field */ - ret = H5Tinsert (tid2, "i", HOFFSET(s1_t,i), H5T_NATIVE_INT); + ret = H5Tinsert (tid2, "i", HOFFSET(s2_t,i), H5T_NATIVE_INT); /* Insert float field */ - ret = H5Tinsert (tid2, "f", HOFFSET(s1_t,f), H5T_NATIVE_FLOAT); + ret = H5Tinsert (tid2, "f", HOFFSET(s2_t,f), H5T_NATIVE_FLOAT); /* Create an array datatype to refer to */ tid1 = H5Tarray_create (tid2,ARRAY1_RANK,tdims1,NULL); @@ -2299,8 +2299,8 @@ static void test_array5(void) typedef struct { /* Typedef for compound datatype */ int i; float f[ARRAY1_DIM1]; - } s1_t; - s1_t wdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information to write */ + } s2_t; + s2_t wdata[SPACE1_DIM1][ARRAY1_DIM1]; /* Information to write */ hid_t fid1; /* HDF5 File IDs */ hid_t dataset; /* Dataset ID */ hid_t sid1; /* Dataspace ID */ @@ -2327,16 +2327,16 @@ static void test_array5(void) sid1 = H5Screate_simple(SPACE1_RANK, sdims1, NULL); /* Create a compound datatype to refer to */ - tid2 = H5Tcreate(H5T_COMPOUND, sizeof(s1_t)); + tid2 = H5Tcreate(H5T_COMPOUND, sizeof(s2_t)); /* Insert integer field */ - ret = H5Tinsert (tid2, "i", HOFFSET(s1_t,i), H5T_NATIVE_INT); + ret = H5Tinsert (tid2, "i", HOFFSET(s2_t,i), H5T_NATIVE_INT); /* Create an array of floats datatype */ tid3 = H5Tarray_create (H5T_NATIVE_FLOAT,ARRAY1_RANK,tdims1,NULL); /* Insert float array field */ - ret = H5Tinsert (tid2, "f", HOFFSET(s1_t,f), tid3); + ret = H5Tinsert (tid2, "f", HOFFSET(s2_t,f), tid3); /* Close array of floats field datatype */ ret=H5Tclose(tid3); diff --git a/tools/h5ls/h5ls.c b/tools/h5ls/h5ls.c index 5a2b0a1..5cd92cd 100644 --- a/tools/h5ls/h5ls.c +++ b/tools/h5ls/h5ls.c @@ -847,10 +847,10 @@ display_enum_type(hid_t type, int ind) printf("%02x", value[i*dst_size+j]); } } else if (H5T_SGN_NONE==H5Tget_sign(native)) { - printf("%"PRINTF_LL_WIDTH"u", + HDfprintf(stdout,"%"PRINTF_LL_WIDTH"u", *((unsigned long_long*)((void*)(value+i*dst_size)))); } else { - printf("%"PRINTF_LL_WIDTH"d", + HDfprintf(stdout,"%"PRINTF_LL_WIDTH"d", *((long_long*)((void*)(value+i*dst_size)))); } } diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index 2341c7f..fc2d034 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -90,8 +90,8 @@ h5tools_close(void) { if (h5tools_init_g) { if (rawdatastream && rawdatastream != stdout) { - if (fclose(rawdatastream)) - perror("closing rawdatastream"); + if (HDfclose(rawdatastream)) + HDperror("closing rawdatastream"); else rawdatastream = NULL; } @@ -204,7 +204,7 @@ h5tools_fopen(const char *fname, char *drivername, size_t drivername_size) /* Save the driver name */ if (drivername && drivername_size) { if (fid >= 0) { - strncpy(drivername, driver[drivernum].name, drivername_size); + HDstrncpy(drivername, driver[drivernum].name, drivername_size); drivername[drivername_size - 1] = '\0'; } else { /*no file opened*/ @@ -271,13 +271,13 @@ h5tools_simple_prefix(FILE *stream, const h5dump_t *info, if (!ctx->need_prefix) return; - memset(&prefix, 0, sizeof(h5tools_str_t)); + HDmemset(&prefix, 0, sizeof(h5tools_str_t)); /* Terminate previous line, if any */ if (ctx->cur_column) { - fputs(OPT(info->line_suf, ""), stream); - putc('\n', stream); - fputs(OPT(info->line_sep, ""), stream); + HDfputs(OPT(info->line_suf, ""), stream); + HDputc('\n', stream); + HDfputs(OPT(info->line_sep, ""), stream); } /* Calculate new prefix */ @@ -298,16 +298,16 @@ h5tools_simple_prefix(FILE *stream, const h5dump_t *info, } if (elmtno == 0 && secnum == 0 && info->line_1st) - fputs(h5tools_str_fmt(&prefix, 0, info->line_1st), stream); + HDfputs(h5tools_str_fmt(&prefix, 0, info->line_1st), stream); else if (secnum && info->line_cont) - fputs(h5tools_str_fmt(&prefix, 0, info->line_cont), stream); + HDfputs(h5tools_str_fmt(&prefix, 0, info->line_cont), stream); else - fputs(h5tools_str_fmt(&prefix, 0, info->line_pre), stream); + HDfputs(h5tools_str_fmt(&prefix, 0, info->line_pre), stream); templength = h5tools_str_len(&prefix); for (i = 0; i < indentlevel; i++){ - fputs(h5tools_str_fmt(&prefix, 0, info->line_indent), stream); + HDfputs(h5tools_str_fmt(&prefix, 0, info->line_indent), stream); templength += h5tools_str_len(&prefix); } @@ -366,7 +366,7 @@ h5tools_dump_simple_data(FILE *stream, const h5dump_t *info, hid_t container, *to the ctx->size_last_dim. */ /* Setup */ - memset(&buffer, 0, sizeof(h5tools_str_t)); + HDmemset(&buffer, 0, sizeof(h5tools_str_t)); size = H5Tget_size(type); if (info->line_ncols > 0) @@ -390,8 +390,8 @@ h5tools_dump_simple_data(FILE *stream, const h5dump_t *info, hid_t container, */ if (info->line_multi_new == 1 && (ctx->cur_column + h5tools_ncols(s) + - strlen(OPT(info->elmt_suf2, " ")) + - strlen(OPT(info->line_suf, ""))) > ncols) { + HDstrlen(OPT(info->elmt_suf2, " ")) + + HDstrlen(OPT(info->line_suf, ""))) > ncols) { if (ctx->prev_multiline) { /* * ... and the previous element also occupied more than one @@ -399,8 +399,8 @@ h5tools_dump_simple_data(FILE *stream, const h5dump_t *info, hid_t container, */ ctx->need_prefix = TRUE; } else if ((ctx->prev_prefix_len + h5tools_ncols(s) + - strlen(OPT(info->elmt_suf2, " ")) + - strlen(OPT(info->line_suf, ""))) <= ncols) { + HDstrlen(OPT(info->elmt_suf2, " ")) + + HDstrlen(OPT(info->line_suf, ""))) <= ncols) { /* * ...but *could* fit on one line otherwise, then we * should end the current line and start this element on its @@ -432,8 +432,8 @@ h5tools_dump_simple_data(FILE *stream, const h5dump_t *info, hid_t container, */ if (info->line_multi_new == 1 && ctx->prev_multiline && (ctx->cur_column + h5tools_ncols(s) + - strlen(OPT(info->elmt_suf2, " ")) + - strlen(OPT(info->line_suf, ""))) > ncols) + HDstrlen(OPT(info->elmt_suf2, " ")) + + HDstrlen(OPT(info->line_suf, ""))) > ncols) ctx->need_prefix = TRUE; /* @@ -463,8 +463,8 @@ h5tools_dump_simple_data(FILE *stream, const h5dump_t *info, hid_t container, */ if ((!info->skip_first || i) && (ctx->cur_column + strlen(section) + - strlen(OPT(info->elmt_suf2, " ")) + - strlen(OPT(info->line_suf, ""))) > ncols) + HDstrlen(OPT(info->elmt_suf2, " ")) + + HDstrlen(OPT(info->line_suf, ""))) > ncols) ctx->need_prefix = 1; /* @@ -477,13 +477,13 @@ h5tools_dump_simple_data(FILE *stream, const h5dump_t *info, hid_t container, h5tools_simple_prefix(stream, info, ctx, i, secnum); } else if ((i || ctx->continuation) && secnum == 0) { - fputs(OPT(info->elmt_suf2, " "), stream); - ctx->cur_column += strlen(OPT(info->elmt_suf2, " ")); + HDfputs(OPT(info->elmt_suf2, " "), stream); + ctx->cur_column += HDstrlen(OPT(info->elmt_suf2, " ")); } /* Print the section */ - fputs(section, stream); - ctx->cur_column += strlen(section); + HDfputs(section, stream); + ctx->cur_column += HDstrlen(section); } ctx->prev_multiline = multiline; @@ -513,7 +513,7 @@ h5tools_dump_simple_subset(FILE *stream, const h5dump_t *info, hid_t dset, { herr_t ret; /*the value to return */ hid_t f_space; /*file data space */ - hsize_t elmtno, i; /*counters */ + hsize_t i; /*counters */ hssize_t zero = 0; /*vector of zeros */ unsigned int flags; /*buffer extent flags */ hsize_t total_size[H5S_MAX_RANK];/*total size of dataset*/ @@ -542,7 +542,7 @@ h5tools_dump_simple_subset(FILE *stream, const h5dump_t *info, hid_t dset, * great and the dimensionality of the items selected for printing must * match the dimensionality of the dataset. */ - memset(&ctx, 0, sizeof(ctx)); + HDmemset(&ctx, 0, sizeof(ctx)); ctx.indent_level = indentlevel; ctx.need_prefix = 1; ctx.ndims = H5Sget_simple_extent_ndims(f_space); @@ -604,7 +604,7 @@ h5tools_dump_simple_subset(FILE *stream, const h5dump_t *info, hid_t dset, } assert(sm_nbytes == (hsize_t)((size_t)sm_nbytes)); /*check for overflow*/ - sm_buf = malloc((size_t)sm_nelmts * p_type_nbytes); + sm_buf = HDmalloc((size_t)sm_nelmts * p_type_nbytes); sm_space = H5Screate_simple(1, &sm_nelmts, NULL); H5Sselect_hyperslab(sm_space, H5S_SELECT_SET, &zero, NULL, &sm_nelmts, NULL); @@ -613,7 +613,7 @@ h5tools_dump_simple_subset(FILE *stream, const h5dump_t *info, hid_t dset, if (H5Dread(dset, p_type, sm_space, f_space, H5P_DEFAULT, sm_buf) < 0) { H5Sclose(f_space); H5Sclose(sm_space); - free(sm_buf); + HDfree(sm_buf); return FAIL; } @@ -629,15 +629,15 @@ h5tools_dump_simple_subset(FILE *stream, const h5dump_t *info, hid_t dset, h5tools_dump_simple_data(stream, info, dset, &ctx, flags, sm_nelmts, p_type, sm_buf); - free(sm_buf); + HDfree(sm_buf); ctx.continuation++; } /* Terminate the output */ if (ctx.cur_column) { - fputs(OPT(info->line_suf, ""), stream); - putc('\n', stream); - fputs(OPT(info->line_sep, ""), stream); + HDfputs(OPT(info->line_suf, ""), stream); + HDputc('\n', stream); + HDfputs(OPT(info->line_sep, ""), stream); } ret = SUCCEED; @@ -707,7 +707,7 @@ h5tools_dump_simple_dset(FILE *stream, const h5dump_t *info, hid_t dset, * great and the dimensionality of the items selected for printing must * match the dimensionality of the dataset. */ - memset(&ctx, 0, sizeof(ctx)); + HDmemset(&ctx, 0, sizeof(ctx)); ctx.indent_level = indentlevel; ctx.need_prefix = 1; ctx.ndims = H5Sget_simple_extent_ndims(f_space); @@ -757,13 +757,13 @@ h5tools_dump_simple_dset(FILE *stream, const h5dump_t *info, hid_t dset, } assert(sm_nbytes == (hsize_t)((size_t)sm_nbytes)); /*check for overflow*/ - sm_buf = malloc((size_t)sm_nbytes); + sm_buf = HDmalloc((size_t)sm_nbytes); sm_nelmts = sm_nbytes / p_type_nbytes; sm_space = H5Screate_simple(1, &sm_nelmts, NULL); /* The stripmine loop */ - memset(hs_offset, 0, sizeof hs_offset); - memset(zero, 0, sizeof zero); + HDmemset(hs_offset, 0, sizeof hs_offset); + HDmemset(zero, 0, sizeof zero); for (elmtno = 0; elmtno < p_nelmts; elmtno += hs_nelmts) { /* Calculate the hyperslab size */ @@ -788,7 +788,7 @@ h5tools_dump_simple_dset(FILE *stream, const h5dump_t *info, hid_t dset, if (H5Dread(dset, p_type, sm_space, f_space, H5P_DEFAULT, sm_buf) < 0) { H5Sclose(f_space); H5Sclose(sm_space); - free(sm_buf); + HDfree(sm_buf); return FAIL; } @@ -818,14 +818,14 @@ h5tools_dump_simple_dset(FILE *stream, const h5dump_t *info, hid_t dset, /* Terminate the output */ if (ctx.cur_column) { - fputs(OPT(info->line_suf, ""), stream); - putc('\n', stream); - fputs(OPT(info->line_sep, ""), stream); + HDfputs(OPT(info->line_suf, ""), stream); + HDputc('\n', stream); + HDfputs(OPT(info->line_sep, ""), stream); } H5Sclose(sm_space); H5Sclose(f_space); - free(sm_buf); + HDfree(sm_buf); return SUCCEED; } @@ -859,7 +859,7 @@ h5tools_dump_simple_mem(FILE *stream, const h5dump_t *info, hid_t obj_id, * great and the dimensionality of the items selected for printing must * match the dimensionality of the dataset. */ - memset(&ctx, 0, sizeof(ctx)); + HDmemset(&ctx, 0, sizeof(ctx)); ctx.ndims = H5Sget_simple_extent_ndims(space); if ((size_t)ctx.ndims > NELMTS(ctx.p_min_idx)) @@ -888,9 +888,9 @@ h5tools_dump_simple_mem(FILE *stream, const h5dump_t *info, hid_t obj_id, /* Terminate the output */ if (ctx.cur_column) { - fputs(OPT(info->line_suf, ""), stream); - putc('\n', stream); - fputs(OPT(info->line_sep, ""), stream); + HDfputs(OPT(info->line_suf, ""), stream); + HDputc('\n', stream); + HDfputs(OPT(info->line_sep, ""), stream); } return SUCCEED; @@ -989,8 +989,8 @@ h5tools_fixtype(hid_t f_type) */ nmembs = H5Tget_nmembers(f_type); assert(nmembs > 0); - memb = calloc((size_t)nmembs, sizeof(hid_t)); - name = calloc((size_t)nmembs, sizeof(char *)); + memb = HDcalloc((size_t)nmembs, sizeof(hid_t)); + name = HDcalloc((size_t)nmembs, sizeof(char *)); for (i = 0, size = 0; i < nmembs; i++) { /* Get the member type and fix it */ @@ -1087,18 +1087,18 @@ h5tools_fixtype(hid_t f_type) done: /* Clean up temp buffers */ if (memb && name) { - register int j; + int j; for (j = 0; j < nmembs; j++) { if (memb[j] >= 0) H5Tclose(memb[j]); if (name[j]) - free(name[j]); + HDfree(name[j]); } - free(memb); - free(name); + HDfree(memb); + HDfree(name); } return m_type; @@ -1151,7 +1151,7 @@ h5tools_dump_dset(FILE *stream, const h5dump_t *info, hid_t dset, hid_t _p_type, stream = stdout; if (!info) { - memset(&info_dflt, 0, sizeof info_dflt); + HDmemset(&info_dflt, 0, sizeof info_dflt); info = &info_dflt; } @@ -1221,7 +1221,7 @@ h5tools_dump_mem(FILE *stream, const h5dump_t *info, hid_t obj_id, hid_t type, stream = stdout; if (!info) { - memset(&info_dflt, 0, sizeof(info_dflt)); + HDmemset(&info_dflt, 0, sizeof(info_dflt)); info = &info_dflt; } diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h index 6a6f859..b4e23d6 100644 --- a/tools/lib/h5tools.h +++ b/tools/lib/h5tools.h @@ -404,7 +404,7 @@ typedef struct h5tools_context_t { /* a structure to hold the subsetting particulars for a dataset */ struct subset_t { - hsize_t *start; + hssize_t *start; hsize_t *stride; hsize_t *count; hsize_t *block; diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c index e594ebd..3922640 100644 --- a/tools/lib/h5tools_str.c +++ b/tools/lib/h5tools_str.c @@ -54,8 +54,8 @@ void h5tools_str_close(h5tools_str_t *str) { if (str && str->nalloc) { - free(str->s); - memset(str, 0, sizeof(h5tools_str_t)); + HDfree(str->s); + HDmemset(str, 0, sizeof(h5tools_str_t)); } } @@ -109,7 +109,7 @@ h5tools_str_append(h5tools_str_t *str/*in,out*/, const char *fmt, ...) /* Make sure we have some memory into which to print */ if (!str->s || str->nalloc <= 0) { str->nalloc = STR_INIT_LEN; - str->s = malloc(str->nalloc); + str->s = HDmalloc(str->nalloc); assert(str->s); str->s[0] = '\0'; str->len = 0; @@ -127,7 +127,7 @@ h5tools_str_append(h5tools_str_t *str/*in,out*/, const char *fmt, ...) /* Try again with twice as much space */ str->nalloc *= 2; - str->s = realloc(str->s, str->nalloc); + str->s = HDrealloc(str->s, str->nalloc); assert(str->s); } @@ -158,7 +158,7 @@ h5tools_str_reset(h5tools_str_t *str/*in,out*/) { if (!str->s || str->nalloc <= 0) { str->nalloc = STR_INIT_LEN; - str->s = malloc(str->nalloc); + str->s = HDmalloc(str->nalloc); assert(str->s); } @@ -220,20 +220,20 @@ h5tools_str_fmt(h5tools_str_t *str/*in,out*/, size_t start, const char *fmt) char _temp[1024], *temp = _temp; /* If the format string is simply "%s" then don't bother doing anything */ - if (!strcmp(fmt, "%s")) + if (!HDstrcmp(fmt, "%s")) return str->s; /* * Save the input value if there is a `%' anywhere in FMT. Otherwise * don't bother because we don't need a temporary copy. */ - if (strchr(fmt, '%')) { + if (HDstrchr(fmt, '%')) { if (str->len - start + 1 > sizeof(_temp)) { - temp = malloc(str->len-start + 1); + temp = HDmalloc(str->len-start + 1); assert(temp); } - strcpy(temp, str->s + start); + HDstrcpy(temp, str->s + start); } /* Reset the output string and append a formatted version */ @@ -242,7 +242,7 @@ h5tools_str_fmt(h5tools_str_t *str/*in,out*/, size_t start, const char *fmt) /* Free the temp buffer if we allocated one */ if (temp != _temp) - free(temp); + HDfree(temp); return str->s; } @@ -347,7 +347,7 @@ h5tools_str_dump_region(h5tools_str_t *str, hid_t region, const h5dump_t *info) alloc_size = nblocks * ndims * 2 * sizeof(ptdata[0]); assert(alloc_size == (hsize_t)((size_t)alloc_size)); /*check for overflow*/ - ptdata = malloc((size_t)alloc_size); + ptdata = HDmalloc((size_t)alloc_size); H5_CHECK_OVERFLOW(nblocks, hssize_t, hsize_t); H5Sget_select_hyper_blocklist(region, (hsize_t)0, (hsize_t)nblocks, ptdata); @@ -370,7 +370,7 @@ h5tools_str_dump_region(h5tools_str_t *str, hid_t region, const h5dump_t *info) h5tools_str_append(str, ")"); } - free(ptdata); + HDfree(ptdata); } /* Print point information */ @@ -379,7 +379,7 @@ h5tools_str_dump_region(h5tools_str_t *str, hid_t region, const h5dump_t *info) alloc_size = npoints * ndims * sizeof(ptdata[0]); assert(alloc_size == (hsize_t)((size_t)alloc_size)); /*check for overflow*/ - ptdata = malloc((size_t)alloc_size); + ptdata = HDmalloc((size_t)alloc_size); H5_CHECK_OVERFLOW(npoints,hssize_t,hsize_t); H5Sget_select_elem_pointlist(region, (hsize_t)0, (hsize_t)npoints, ptdata); @@ -397,7 +397,7 @@ h5tools_str_dump_region(h5tools_str_t *str, hid_t region, const h5dump_t *info) h5tools_str_append(str, ")"); } - free(ptdata); + HDfree(ptdata); } h5tools_str_append(str, "}"); @@ -450,7 +450,7 @@ h5tools_print_char(h5tools_str_t *str, const h5dump_t *info, unsigned char ch) h5tools_str_append(str, "\\t"); break; default: - if (isprint(ch)) + if (HDisprint(ch)) h5tools_str_append(str, "%c", (char)ch); else h5tools_str_append(str, "\\%03o", ch); @@ -533,14 +533,14 @@ h5tools_str_sprint(h5tools_str_t *str, const h5dump_t *info, hid_t container, for (i = 0; i < n; i++) h5tools_str_append(str, OPT(info->fmt_raw, "%02x"), ucp_vp[i]); } else if (H5Tequal(type, H5T_NATIVE_FLOAT)) { - memcpy(&tempfloat, vp, sizeof(float)); + HDmemcpy(&tempfloat, vp, sizeof(float)); h5tools_str_append(str, OPT(info->fmt_float, "%g"), tempfloat); } else if (H5Tequal(type, H5T_NATIVE_DOUBLE)) { - memcpy(&tempdouble, vp, sizeof(double)); + HDmemcpy(&tempdouble, vp, sizeof(double)); h5tools_str_append(str, OPT(info->fmt_double, "%g"), tempdouble); } else if (info->ascii && (H5Tequal(type, H5T_NATIVE_SCHAR) || H5Tequal(type, H5T_NATIVE_UCHAR))) { - h5tools_print_char(str, info, *ucp_vp); + h5tools_print_char(str, info, (unsigned char)*ucp_vp); } else if (H5T_STRING == H5Tget_class(type)) { unsigned int i; @@ -578,7 +578,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5dump_t *info, hid_t container, } /* Print the character */ - h5tools_print_char(str, info, ucp_vp[i]); + h5tools_print_char(str, info, (unsigned char)ucp_vp[i]); /* Print the repeat count */ if (info->str_repeat && j > info->str_repeat) { @@ -600,53 +600,53 @@ h5tools_str_sprint(h5tools_str_t *str, const h5dump_t *info, hid_t container, /*empty string*/ h5tools_str_append(str, "\"\""); } else if (H5Tequal(type, H5T_NATIVE_INT)) { - memcpy(&tempint, vp, sizeof(int)); + HDmemcpy(&tempint, vp, sizeof(int)); h5tools_str_append(str, OPT(info->fmt_int, "%d"), tempint); } else if (H5Tequal(type, H5T_NATIVE_UINT)) { - memcpy(&tempuint, vp, sizeof(unsigned int)); + HDmemcpy(&tempuint, vp, sizeof(unsigned int)); h5tools_str_append(str, OPT(info->fmt_uint, "%u"), tempuint); } else if (H5Tequal(type, H5T_NATIVE_SCHAR)) { h5tools_str_append(str, OPT(info->fmt_schar, "%d"), *cp_vp); } else if (H5Tequal(type, H5T_NATIVE_UCHAR)) { h5tools_str_append(str, OPT(info->fmt_uchar, "%u"), *ucp_vp); } else if (H5Tequal(type, H5T_NATIVE_SHORT)) { - memcpy(&tempshort, vp, sizeof(short)); + HDmemcpy(&tempshort, vp, sizeof(short)); h5tools_str_append(str, OPT(info->fmt_short, "%d"), tempshort); } else if (H5Tequal(type, H5T_NATIVE_USHORT)) { - memcpy(&tempushort, vp, sizeof(unsigned short)); + HDmemcpy(&tempushort, vp, sizeof(unsigned short)); h5tools_str_append(str, OPT(info->fmt_ushort, "%u"), tempushort); } else if (H5Tequal(type, H5T_NATIVE_LONG)) { - memcpy(&templong, vp, sizeof(long)); + HDmemcpy(&templong, vp, sizeof(long)); h5tools_str_append(str, OPT(info->fmt_long, "%ld"), templong); } else if (H5Tequal(type, H5T_NATIVE_ULONG)) { - memcpy(&tempulong, vp, sizeof(unsigned long)); + HDmemcpy(&tempulong, vp, sizeof(unsigned long)); h5tools_str_append(str, OPT(info->fmt_ulong, "%lu"), tempulong); } else if (H5Tequal(type, H5T_NATIVE_LLONG)) { - memcpy(&templlong, vp, sizeof(long_long)); + HDmemcpy(&templlong, vp, sizeof(long_long)); h5tools_str_append(str, OPT(info->fmt_llong, fmt_llong), templlong); } else if (H5Tequal(type, H5T_NATIVE_ULLONG)) { - memcpy(&tempullong, vp, sizeof(unsigned long_long)); + HDmemcpy(&tempullong, vp, sizeof(unsigned long_long)); h5tools_str_append(str, OPT(info->fmt_ullong, fmt_ullong), tempullong); } else if (H5Tequal(type, H5T_NATIVE_HSSIZE)) { if (sizeof(hssize_t) == sizeof(int)) { - memcpy(&tempint, vp, sizeof(int)); + HDmemcpy(&tempint, vp, sizeof(int)); h5tools_str_append(str, OPT(info->fmt_int, "%d"), tempint); } else if (sizeof(hssize_t) == sizeof(long)) { - memcpy(&templong, vp, sizeof(long)); + HDmemcpy(&templong, vp, sizeof(long)); h5tools_str_append(str, OPT(info->fmt_long, "%ld"), templong); } else { - memcpy(&templlong, vp, sizeof(long_long)); + HDmemcpy(&templlong, vp, sizeof(long_long)); h5tools_str_append(str, OPT(info->fmt_llong, fmt_llong), templlong); } } else if (H5Tequal(type, H5T_NATIVE_HSIZE)) { if (sizeof(hsize_t) == sizeof(int)) { - memcpy(&tempuint, vp, sizeof(unsigned int)); + HDmemcpy(&tempuint, vp, sizeof(unsigned int)); h5tools_str_append(str, OPT(info->fmt_uint, "%u"), tempuint); } else if (sizeof(hsize_t) == sizeof(long)) { - memcpy(&tempulong, vp, sizeof(long)); + HDmemcpy(&tempulong, vp, sizeof(long)); h5tools_str_append(str, OPT(info->fmt_ulong, "%lu"), tempulong); } else { - memcpy(&tempullong, vp, sizeof(unsigned long_long)); + HDmemcpy(&tempullong, vp, sizeof(unsigned long_long)); h5tools_str_append(str, OPT(info->fmt_ullong, fmt_ullong), tempullong); } } else if (H5Tget_class(type) == H5T_COMPOUND) { @@ -677,7 +677,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5dump_t *info, hid_t container, /* The name */ name = H5Tget_member_name(type, j); h5tools_str_append(str, OPT(info->cmpd_name, ""), name); - free(name); + HDfree(name); /* The value */ offset = H5Tget_member_offset(type, j); @@ -920,50 +920,50 @@ h5tools_escape(char *s/*in,out*/, size_t size, int escape_spaces) for (i = 0; i < n; i++) { switch (s[i]) { - case '"': - escape = "\\\""; - break; - case '\\': - escape = "\\\\"; - break; - case '\b': - escape = "\\b"; - break; - case '\f': - escape = "\\f"; - break; - case '\n': - escape = "\\n"; - break; - case '\r': - escape = "\\r"; - break; - case '\t': - escape = "\\t"; - break; - case ' ': - escape = escape_spaces ? "\\ " : NULL; - break; - default: - if (!isprint((int)*s)) { - sprintf(octal, "\\%03o", (unsigned char)s[i]); - escape = octal; - } else { - escape = NULL; - } - - break; + case '"': + escape = "\\\""; + break; + case '\\': + escape = "\\\\"; + break; + case '\b': + escape = "\\b"; + break; + case '\f': + escape = "\\f"; + break; + case '\n': + escape = "\\n"; + break; + case '\r': + escape = "\\r"; + break; + case '\t': + escape = "\\t"; + break; + case ' ': + escape = escape_spaces ? "\\ " : NULL; + break; + default: + if (!isprint((int)*s)) { + sprintf(octal, "\\%03o", (unsigned char)s[i]); + escape = octal; + } else { + escape = NULL; + } + + break; } if (escape) { - size_t esc_size = strlen(escape); + size_t esc_size = HDstrlen(escape); if (n + esc_size + 1 > size) /*would overflow*/ return NULL; - memmove(s + i + esc_size, s + i, (n - i) + 1); /*make room*/ - memcpy(s + i, escape, esc_size); /*insert*/ + HDmemmove(s + i + esc_size, s + i, (n - i) + 1); /*make room*/ + HDmemcpy(s + i, escape, esc_size); /*insert*/ n += esc_size; i += esc_size - 1; } diff --git a/tools/lib/h5tools_str.h b/tools/lib/h5tools_str.h index 58b5ba9..b9aba72 100644 --- a/tools/lib/h5tools_str.h +++ b/tools/lib/h5tools_str.h @@ -24,7 +24,7 @@ extern char *h5tools_str_prefix(h5tools_str_t *str, const h5dump_t *info, hsize_t elmtno, int ndims, hsize_t min_idx[], hsize_t max_idx[]); extern int h5tools_str_dump_region(h5tools_str_t *, hid_t, const h5dump_t *); -extern void h5tools_print_char(h5tools_str_t *, const h5dump_t *, unsigned char); +extern void h5tools_print_char(h5tools_str_t *str, const h5dump_t *info, unsigned char ch); extern char *h5tools_str_sprint(h5tools_str_t *str, const h5dump_t *info, hid_t container, hid_t type, void *vp, h5tools_context_t *ctx); diff --git a/tools/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c index a6050ca..9f5fa0a 100644 --- a/tools/lib/h5tools_utils.c +++ b/tools/lib/h5tools_utils.c @@ -52,13 +52,13 @@ error_msg(const char *progname, const char *fmt, ...) va_list ap; va_start(ap, fmt); - fflush(stdout); + HDfflush(stdout); #ifdef WIN32 - fprintf(stdout, "%s error: ", progname); - vfprintf(stdout, fmt, ap); + HDfprintf(stdout, "%s error: ", progname); + HDvfprintf(stdout, fmt, ap); #else - fprintf(stderr, "%s error: ", progname); - vfprintf(stderr, fmt, ap); + HDfprintf(stderr, "%s error: ", progname); + HDvfprintf(stderr, fmt, ap); #endif va_end(ap); @@ -86,9 +86,14 @@ warn_msg(const char *progname, const char *fmt, ...) va_list ap; va_start(ap, fmt); - fflush(stdout); - fprintf(stderr, "%s warning: ", progname); - vfprintf(stderr, fmt, ap); + HDfflush(stdout); +#ifdef WIN32 + HDfprintf(stdout, "%s warning: ", progname); + HDvfprintf(stdout, fmt, ap); +#else /* WIN32 */ + HDfprintf(stderr, "%s warning: ", progname); + HDvfprintf(stderr, fmt, ap); +#endif /* WIN32 */ va_end(ap); } @@ -122,7 +127,7 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti /* check for more flag-like tokens */ if (opt_ind >= argc || argv[opt_ind][0] != '-' || argv[opt_ind][1] == '\0') { return EOF; - } else if (strcmp(argv[opt_ind], "--") == 0) { + } else if (HDstrcmp(argv[opt_ind], "--") == 0) { opt_ind++; return EOF; } @@ -131,12 +136,12 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti if (sp == 1 && argv[opt_ind][0] == '-' && argv[opt_ind][1] == '-') { /* long command line option */ const char *arg = &argv[opt_ind][2]; - register int i; + int i; for (i = 0; l_opts && l_opts[i].name; i++) { - size_t len = strlen(l_opts[i].name); + size_t len = HDstrlen(l_opts[i].name); - if (strncmp(arg, l_opts[i].name, len) == 0) { + if (HDstrncmp(arg, l_opts[i].name, len) == 0) { /* we've found a matching long command line flag */ opt_opt = l_opts[i].shortval; @@ -147,7 +152,7 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti opt_arg = argv[++opt_ind]; } else if (l_opts[i].has_arg == require_arg) { if (opt_err) - fprintf(stderr, + HDfprintf(stderr, "%s: option required for \"--%s\" flag\n", argv[0], arg); @@ -156,7 +161,7 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti } else { if (arg[len] == '=') { if (opt_err) - fprintf(stderr, + HDfprintf(stderr, "%s: no option required for \"%s\" flag\n", argv[0], arg); @@ -173,7 +178,7 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti if (l_opts[i].name == NULL) { /* exhausted all of the l_opts we have and still didn't match */ if (opt_err) - fprintf(stderr, "%s: unknown option \"%s\"\n", argv[0], arg); + HDfprintf(stderr, "%s: unknown option \"%s\"\n", argv[0], arg); opt_opt = '?'; } @@ -188,7 +193,7 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti if (opt_opt == ':' || (cp = strchr(opts, opt_opt)) == 0) { if (opt_err) - fprintf(stderr, "%s: unknown option \"%c\"\n", + HDfprintf(stderr, "%s: unknown option \"%c\"\n", argv[0], opt_opt); /* if no chars left in this token, move to next token */ @@ -207,7 +212,7 @@ get_option(int argc, const char **argv, const char *opts, const struct long_opti opt_arg = &argv[opt_ind++][sp + 1]; } else if (++opt_ind >= argc) { if (opt_err) - fprintf(stderr, + HDfprintf(stderr, "%s: value expected for option \"%c\"\n", argv[0], opt_opt); @@ -255,7 +260,7 @@ indentation(int x) while (x-- > 0) printf(" "); } else { - fprintf(stderr, "error: the indentation exceeds the number of cols.\n"); + HDfprintf(stderr, "error: the indentation exceeds the number of cols.\n"); exit(1); } } @@ -302,11 +307,11 @@ void init_table(table_t **tbl) { int i; - table_t *table = malloc(sizeof(table_t)); + table_t *table = HDmalloc(sizeof(table_t)); table->size = 20; table->nobjs = 0; - table->objs = malloc(table->size * sizeof(obj_t)); + table->objs = HDmalloc(table->size * sizeof(obj_t)); for (i = 0; i < table->size; i++) { table->objs[i].objno[0] = table->objs[i].objno[1] = 0; @@ -334,7 +339,7 @@ void init_prefix(char **prefix, int prefix_len) { assert(prefix_len > 0); - *prefix = calloc((size_t)prefix_len, 1); + *prefix = HDcalloc((size_t)prefix_len, 1); } @@ -377,7 +382,7 @@ free_table(table_t **table) int search_obj(table_t *table, unsigned long *objno) { - register int i; + int i; for (i = 0; i < table->nobjs; i++) if (table->objs[i].objno[0] == *objno && table->objs[i].objno[1] == *(objno + 1)) @@ -409,7 +414,7 @@ find_objs(hid_t group, const char *name, void *op_data) H5G_stat_t statbuf; char *tmp; find_objs_t *info = (find_objs_t*)op_data; - register int i; + int i; if (info->threshold > 1) /*will get an infinite loop if greater than 1*/ @@ -417,93 +422,93 @@ find_objs(hid_t group, const char *name, void *op_data) H5Gget_objinfo(group, name, TRUE, &statbuf); - tmp = malloc(strlen(info->prefix) + strlen(name) + 2); - strcpy(tmp, info->prefix); + tmp = HDmalloc(HDstrlen(info->prefix) + HDstrlen(name) + 2); + HDstrcpy(tmp, info->prefix); switch (statbuf.type) { - case H5G_GROUP: - if ((obj = H5Gopen(group, name)) >= 0) { - if (info->prefix_len < (int)(strlen(info->prefix) + strlen(name) + 2)) { - info->prefix_len *= 2; - info->prefix = realloc(info->prefix, - info->prefix_len * sizeof(char)); - } + case H5G_GROUP: + if ((obj = H5Gopen(group, name)) >= 0) { + if (info->prefix_len < (int)(HDstrlen(info->prefix) + HDstrlen(name) + 2)) { + info->prefix_len *= 2; + info->prefix = HDrealloc(info->prefix, + info->prefix_len * sizeof(char)); + } - strcat(strcat(info->prefix,"/"), name); + HDstrcat(HDstrcat(info->prefix,"/"), name); - if (statbuf.nlink > info->threshold) { - if (search_obj(info->group_table, statbuf.objno) == FAIL) { - add_obj(info->group_table, statbuf.objno, info->prefix); - H5Giterate(obj, ".", NULL, find_objs, (void *)info); + if (statbuf.nlink > info->threshold) { + if (search_obj(info->group_table, statbuf.objno) == FAIL) { + add_obj(info->group_table, statbuf.objno, info->prefix); + H5Giterate(obj, ".", NULL, find_objs, (void *)info); + } + } else { + H5Giterate (obj, ".", NULL, find_objs, (void *)info); } - } else { - H5Giterate (obj, ".", NULL, find_objs, (void *)info); - } - strcpy(info->prefix, tmp); - H5Gclose (obj); - } else { - info->status = 1; - } + HDstrcpy(info->prefix, tmp); + H5Gclose (obj); + } else { + info->status = 1; + } - break; + break; - case H5G_DATASET: - strcat(tmp,"/"); - strcat(tmp,name); /* absolute name of the data set */ + case H5G_DATASET: + HDstrcat(tmp,"/"); + HDstrcat(tmp,name); /* absolute name of the data set */ - if (statbuf.nlink > info->threshold && - search_obj(info->dset_table, statbuf.objno) == FAIL) - add_obj(info->dset_table, statbuf.objno, tmp); + if (statbuf.nlink > info->threshold && + search_obj(info->dset_table, statbuf.objno) == FAIL) + add_obj(info->dset_table, statbuf.objno, tmp); - if ((obj = H5Dopen (group, name)) >= 0) { - type = H5Dget_type(obj); + if ((obj = H5Dopen (group, name)) >= 0) { + type = H5Dget_type(obj); - if (H5Tcommitted(type) > 0) { - H5Gget_objinfo(type, ".", TRUE, &statbuf); + if (H5Tcommitted(type) > 0) { + H5Gget_objinfo(type, ".", TRUE, &statbuf); - if (search_obj(info->type_table, statbuf.objno) == FAIL) { - add_obj(info->type_table, statbuf.objno, tmp); - info->type_table->objs[info->type_table->nobjs - 1].objflag = 0; + if (search_obj(info->type_table, statbuf.objno) == FAIL) { + add_obj(info->type_table, statbuf.objno, tmp); + info->type_table->objs[info->type_table->nobjs - 1].objflag = 0; + } } - } - H5Tclose(type); - H5Dclose (obj); - } else { - info->status = 1; - } - - break; + H5Tclose(type); + H5Dclose (obj); + } else { + info->status = 1; + } + + break; - case H5G_TYPE: - strcat(tmp,"/"); - strcat(tmp,name); /* absolute name of the type */ - i = search_obj(info->type_table, statbuf.objno); + case H5G_TYPE: + HDstrcat(tmp,"/"); + HDstrcat(tmp,name); /* absolute name of the type */ + i = search_obj(info->type_table, statbuf.objno); - if (i == FAIL) { - add_obj(info->type_table, statbuf.objno, tmp) ; + if (i == FAIL) { + add_obj(info->type_table, statbuf.objno, tmp) ; - /* named data type */ - info->type_table->objs[info->type_table->nobjs-1].recorded = 1; + /* named data type */ + info->type_table->objs[info->type_table->nobjs-1].recorded = 1; - /* named data type */ - info->type_table->objs[info->type_table->nobjs-1].objflag = 1; - } else { - strcpy (info->type_table->objs[i].objname, tmp); - info->type_table->objs[i].recorded = 1; + /* named data type */ + info->type_table->objs[info->type_table->nobjs-1].objflag = 1; + } else { + strcpy (info->type_table->objs[i].objname, tmp); + info->type_table->objs[i].recorded = 1; - /* named data type */ - info->type_table->objs[info->type_table->nobjs-1].objflag = 1; - } + /* named data type */ + info->type_table->objs[info->type_table->nobjs-1].objflag = 1; + } - break; + break; - default: - break; + default: + break; } - free(tmp); + HDfree(tmp); return SUCCEED; } @@ -524,7 +529,7 @@ find_objs(hid_t group, const char *name, void *op_data) void dump_table(char* tablename, table_t *table) { - register int i; + int i; printf("%s: # of entries = %d\n", tablename,table->nobjs); @@ -612,7 +617,7 @@ set_tableflag(table_t *table, int idx) char * get_objectname(table_t *table, int idx) { - return strdup(table->objs[idx].objname); + return HDstrdup(table->objs[idx].objname); } @@ -633,11 +638,11 @@ get_objectname(table_t *table, int idx) static void add_obj(table_t *table, unsigned long *objno, char *objname) { - register int i; + int i; if (table->nobjs == table->size) { table->size *= 2; - table->objs = realloc(table->objs, table->size * sizeof(obj_t)); + table->objs = HDrealloc(table->objs, table->size * sizeof(obj_t)); for (i = table->nobjs; i < table->size; i++) { table->objs[i].objno[0] = table->objs[i].objno[1] = 0; @@ -650,5 +655,5 @@ add_obj(table_t *table, unsigned long *objno, char *objname) i = table->nobjs++; table->objs[i].objno[0] = objno[0]; table->objs[i].objno[1] = objno[1]; - strcpy(table->objs[i].objname, objname); + HDstrcpy(table->objs[i].objname, objname); } |