diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2002-06-19 13:06:57 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2002-06-19 13:06:57 (GMT) |
commit | 6d7cbd13dce1ae24446ed84a88c64c68598dc6bf (patch) | |
tree | 9debd9624be08fb8ff72f91e2416ae853939e2fc /hl/tools | |
parent | a00188dde45dfd59728e1e68ddbf6cad5e1d014c (diff) | |
download | hdf5-6d7cbd13dce1ae24446ed84a88c64c68598dc6bf.zip hdf5-6d7cbd13dce1ae24446ed84a88c64c68598dc6bf.tar.gz hdf5-6d7cbd13dce1ae24446ed84a88c64c68598dc6bf.tar.bz2 |
[svn-r5668] Purpose:
Code cleanup
Description:
Turn on more warnings in the IRIX builds and clean them up.
Platforms tested:
IRIX64 6.5 (modi4) w/parallel, both -n32 and the default (-64?) mode
Diffstat (limited to 'hl/tools')
-rw-r--r-- | hl/tools/gif2h5/decompress.c | 24 | ||||
-rw-r--r-- | hl/tools/gif2h5/gif.h | 1 | ||||
-rw-r--r-- | hl/tools/gif2h5/gifread.c | 10 | ||||
-rw-r--r-- | hl/tools/gif2h5/hdf2gif.c | 29 | ||||
-rw-r--r-- | hl/tools/gif2h5/hdfgifwr.c | 40 | ||||
-rw-r--r-- | hl/tools/gif2h5/readhdf.c | 11 | ||||
-rw-r--r-- | hl/tools/gif2h5/writehdf.c | 59 |
7 files changed, 59 insertions, 115 deletions
diff --git a/hl/tools/gif2h5/decompress.c b/hl/tools/gif2h5/decompress.c index 18dbb3e..ff6c4ca 100644 --- a/hl/tools/gif2h5/decompress.c +++ b/hl/tools/gif2h5/decompress.c @@ -15,19 +15,15 @@ char *cmd; FILE *fp; +static WORD + XC = 0, YC = 0, /* Output X and Y coords of current pixel */ + CodeSize, /* Code size, read from GIF header */ + InitCodeSize, /* Starting code size, used during Clear */ + BytesPerScanline, /* Bytes per scanline in output raster */ + IWidth, IHeight; /* image dimensions */ 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 */ MaxCode, /* limiting value for current code size */ ClearCode, /* GIF clear code */ @@ -73,7 +69,8 @@ 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 +84,7 @@ ReadCode() } -AddToPixel(Index) -BYTE Index; +static void AddToPixel(BYTE Index) { if (YC<IHeight) *(Image + YC * BytesPerScanline + XC) = Index; @@ -154,7 +150,7 @@ GIFHEAD *GifHead; OutCount = 0; BitOffset = 0; - DataMask = (WORD)((1L << ((GifHead->PackedField & 0x07) +1)) -1); + DataMask = (1 << ((GifHead->PackedField & 0x07) +1)) -1; Raster = GifImageDesc->GIFImage; diff --git a/hl/tools/gif2h5/gif.h b/hl/tools/gif2h5/gif.h index 7f1d042..9e4f9e8 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/gifread.c b/hl/tools/gif2h5/gifread.c index f2fefff..c7b7b96 100644 --- a/hl/tools/gif2h5/gifread.c +++ b/hl/tools/gif2h5/gifread.c @@ -2,6 +2,9 @@ #include <stdlib.h> #include "gif.h" +static BYTE * +ReadDataSubBlocks(BYTE **MemGif2 , WORD *DSize); + int EndianOrder; int i; @@ -53,7 +56,7 @@ BYTE **MemGif2; /* GIF image file input FILE stream */ 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); } @@ -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,6 @@ WORD *DSize; } - /**ptr1++ = (BYTE) NULL; /* Add NULL to simulate Terminator value */ *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 1963a20..6443627 100644 --- a/hl/tools/gif2h5/hdf2gif.c +++ b/hl/tools/gif2h5/hdf2gif.c @@ -52,7 +52,7 @@ 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"); } @@ -68,12 +68,9 @@ 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 */ - int loop_times; /* number of times to loop, i'm going to treat it as a yes or no */ BYTE* b; @@ -86,10 +83,8 @@ int main(int argc , char **argv) { /*int LeftOfs, TopOfs;*/ int ColorMapSize, InitCodeSize, Background, BitsPerPixel; int j,nc; - int w,h,i; + int w,i; int numcols = 256; - int CountDown; - int curx , cury; int time_out = 0; /* time between two images in the animation */ int n_images , index; @@ -207,19 +202,7 @@ int main(int argc , char **argv) { assert(dim_sizes[1]==(hsize_t)((int)dim_sizes[1])); RWidth = (int)dim_sizes[1]; RHeight = (int)dim_sizes[0]; - w = (int)dim_sizes[1]; - h = (int)dim_sizes[0]; - -#ifdef UNUSED - /* w = dim_sizes[1]; - h = dim_sizes[0]; - - */ - LeftOfs = TopOfs = 0; -#endif /*UNUSED */ - - /* If the first image does not have a palette, I make my own global color table ** Obviously this is not the best thing to do, better steps would be: ** 1. Check for either a global palette or a global attribute called palette @@ -266,13 +249,9 @@ int main(int argc , char **argv) { ColorMapSize = 1 << BitsPerPixel; - CountDown = w * h; /* # of pixels we'll be doing */ - if (BitsPerPixel <= 1) InitCodeSize = 2; else InitCodeSize = BitsPerPixel; - curx = cury = 0; - if (!fpGif) { fprintf(stderr, "WriteGIF: file not open for writing\n" ); return (1); @@ -285,11 +264,9 @@ int main(int argc , char **argv) { /* Write out the GIF header and logical screen descriptor */ if (n_images > 1) { fwrite("GIF89a", 1, 6, fpGif); /* the GIF magic number */ - loop_times = 0; } else { fwrite("GIF87a", 1, 6, fpGif); /* the GIF magic number */ - loop_times = 1; } putword(RWidth, fpGif); /* screen descriptor */ @@ -305,7 +282,7 @@ int main(int argc , char **argv) { fputc(0, fpGif); /* future expansion byte */ - /* If loop_times is 0 , put in the application extension to make the gif anime loop + /* If time_out>0, put in the application extension to make the gif anime loop ** indefinitely */ if (time_out > 0) { diff --git a/hl/tools/gif2h5/hdfgifwr.c b/hl/tools/gif2h5/hdfgifwr.c index 7277e13..3c15477 100644 --- a/hl/tools/gif2h5/hdfgifwr.c +++ b/hl/tools/gif2h5/hdfgifwr.c @@ -73,13 +73,10 @@ typedef long int count_int; /* MONO returns total intensity of r,g,b components */ #define MONO(rd,gn,bl) (((rd)*11 + (gn)*16 + (bl)*5) >> 5) /*.33R+ .5G+ .17B*/ -static int Width, Height; -static int curx, cury; -static long CountDown; -static int Interlace; - #ifdef __STDC__ +#ifdef UNUSED static void putword(int, FILE *); +#endif /* UNUSED */ static void compress(int, FILE *, byte *, int); static void output(int); static void cl_block(void); @@ -88,15 +85,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(); +#ifdef UNUSED +static void putword(); +#endif /* UNUSED */ +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]; +static byte pc2nc[256]; -void xvbzero(s, len) - char *s; - int len; +static void xvbzero(char *s, size_t len) { for ( ; len>0; len--) *s++ = 0; } @@ -110,36 +108,18 @@ int hdfWriteGIF(fp, pic, ptype, w, h, rmap, gmap, bmap, pc2ncmap, numcols, colo int numcols, colorstyle; int BitsPerPixel; { - int RWidth, RHeight; - int LeftOfs, TopOfs; - int ColorMapSize, InitCodeSize, Background; + int InitCodeSize; int i; byte *pic8; pic8 = pic; - Interlace = 0; - Background = 0; - for (i=0; i<256; i++) { pc2nc[i] = pc2ncmap[i]; - r1[i] = rmap[i]; - g1[i] = gmap[i]; - b1[i] = bmap[i]; } - ColorMapSize = 1 << BitsPerPixel; - - RWidth = Width = w; - RHeight = Height = h; - LeftOfs = TopOfs = 0; - - CountDown = w * h; /* # of pixels we'll be doing */ - if (BitsPerPixel <= 1) InitCodeSize = 2; else InitCodeSize = BitsPerPixel; - curx = cury = 0; - if (!fp) { fprintf(stderr, "WriteGIF: file not open for writing\n" ); return (1); @@ -155,6 +135,7 @@ int hdfWriteGIF(fp, pic, ptype, w, h, rmap, gmap, bmap, pc2ncmap, numcols, colo +#ifdef UNUSED /******************************/ static void putword(w, fp) int w; @@ -166,6 +147,7 @@ FILE *fp; fputc((w>>8)&0xff,fp); } +#endif /* UNUSED */ diff --git a/hl/tools/gif2h5/readhdf.c b/hl/tools/gif2h5/readhdf.c index 602c48f..5b9c9d1 100644 --- a/hl/tools/gif2h5/readhdf.c +++ b/hl/tools/gif2h5/readhdf.c @@ -32,7 +32,6 @@ int ReadHDF(BYTE** data , CHAR *pal_name) { hid_t fHfile; /* H5 file to open */ - herr_t status; /* status variable */ hid_t dspace; /* dataspace identifier for the the dataset */ hid_t dset; /* dataset identifier */ @@ -89,7 +88,7 @@ int ReadHDF(BYTE** data , } /* get the actual image */ - if ((status = H5Dread(dset , H5Dget_type(dset) , H5S_ALL , H5S_ALL , H5P_DEFAULT , *data)) < 0) { + if (H5Dread(dset , H5Dget_type(dset) , H5S_ALL , H5S_ALL , H5P_DEFAULT , *data) < 0) { fprintf(stderr , "Unable to read data \n"); cleanup(*data); return -1; @@ -140,7 +139,7 @@ int ReadHDF(BYTE** data , } /* get the actual palette */ - if ((status = H5Dread(pal_set , H5Dget_type(pal_set) , H5S_ALL , H5S_ALL , H5P_DEFAULT , temp_buf)) < 0) { + if (H5Dread(pal_set , H5Dget_type(pal_set) , H5S_ALL , H5S_ALL , H5P_DEFAULT , temp_buf) < 0) { fprintf(stderr , "Unable to read data \n"); cleanup(*data); cleanup(temp_buf); @@ -165,9 +164,9 @@ int ReadHDF(BYTE** data , } /* close everything */ - status = H5Dclose(dset); - status = H5Sclose(dspace); - status = H5Fclose(fHfile); + H5Dclose(dset); + H5Sclose(dspace); + H5Fclose(fHfile); return 0; } diff --git a/hl/tools/gif2h5/writehdf.c b/hl/tools/gif2h5/writehdf.c index 53cf9be..1eb49fd 100644 --- a/hl/tools/gif2h5/writehdf.c +++ b/hl/tools/gif2h5/writehdf.c @@ -13,7 +13,6 @@ int write_text_attribute(hid_t dataset_id , char *attr_name , char *attr_value) hsize_t attr_dims_size; /* dimensions for the attribute */ hid_t attr_dataspace_id; /* dataspaces needed for the various attributes */ hid_t attr_attr_id; /* attribute id */ - herr_t status; /* check return status */ hid_t attr_type_id; @@ -36,15 +35,15 @@ int write_text_attribute(hid_t dataset_id , char *attr_name , char *attr_value) attr_attr_id = H5Acreate(dataset_id , attr_name , attr_type_id , attr_dataspace_id , H5P_DEFAULT); /* write out the attribute data */ - if ((status = H5Awrite(attr_attr_id , attr_type_id , attr_value)) < 0) + if (H5Awrite(attr_attr_id , attr_type_id , attr_value) < 0) return -1; /* close the attribute */ - if ((status = H5Aclose(attr_attr_id)) < 0) + if (H5Aclose(attr_attr_id) < 0) return -1; /* close the dataspace */ - if ((status = H5Sclose(attr_dataspace_id)) < 0) { + if (H5Sclose(attr_dataspace_id) < 0) { fprintf(stderr , "Unable to close attribute dataspace. Aborting \n"); return -1; } @@ -62,23 +61,14 @@ char *GIFFileName; GIFHEAD gifHead; /* GIF Header structure */ 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 */ - + long ImageCount; /* number of images */ char ImageName[256]; /* Image name for the GR Image */ - /* CommentName[256], - ApplicationName[256], - PlainTextName[256]; */ - char GroupName[VSNAMELENMAX]; /* so that we can name the subgroups appropriately */ /* H5 variables */ hid_t file_id; /* H5 file id */ hid_t image_id; /* H5 id for the whole image */ hid_t pal_id; /* H5 id for the palette */ - herr_t status; /* status variable */ hobj_ref_t pal_ref; /* Create a reference for the palette */ /* temp counter */ @@ -93,10 +83,7 @@ char *GIFFileName; gifHead = *(GifMemoryStruct.GifHeader); /* get some data from gifHead */ - ImageCount = (WORD)gifHead.ImageCount; - CommentCount = (WORD)gifHead.CommentCount; - ApplicationCount = (WORD)gifHead.ApplicationCount; - PlainTextCount = (WORD)gifHead.PlainTextCount; + ImageCount = gifHead.ImageCount; /* get the main group name from GIFFileName */ GroupName[0]= '/'; @@ -145,7 +132,7 @@ char *GIFFileName; /* write the palette data out */ /****** Ask Elena about VOIDP ******/ - if ((status = H5Dwrite(pal_id , H5T_NATIVE_UINT8 , H5S_ALL , H5S_ALL , H5P_DEFAULT , (void *)gifHead.HDFPalette)) < 0) { + if (H5Dwrite(pal_id , H5T_NATIVE_UINT8 , H5S_ALL , H5S_ALL , H5P_DEFAULT , (void *)gifHead.HDFPalette) < 0) { fprintf(stderr , "Error writing dataset. Aborting...\n"); return -1; } @@ -183,36 +170,36 @@ char *GIFFileName; ref_dataset_id = H5Dcreate(image_id , "Palette Reference" , H5T_STD_REF_OBJ , ref_dataspace_id , H5P_DEFAULT); /* create a reference to the palette */ - if ((status = H5Rcreate(&pal_ref , image_id , "Global Palette" , H5R_OBJECT , -1)) < 0) { + if (H5Rcreate(&pal_ref , image_id , "Global Palette" , H5R_OBJECT , -1) < 0) { fprintf(stderr , "Unable to create palette reference\n"); return -1; } /* write the reference out */ - if ((status = H5Dwrite(ref_dataset_id , H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL , H5P_DEFAULT, &pal_ref)) < 0) { + if (H5Dwrite(ref_dataset_id , H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL , H5P_DEFAULT, &pal_ref) < 0) { fprintf(stderr , "Unable to write Palette Reference"); return -1; } /* close dataset */ - if ((status = H5Dclose(ref_dataset_id)) < 0) { + if (H5Dclose(ref_dataset_id) < 0) { fprintf(stderr , "Unable to close palette dataset.\n"); return -1; } /* close dataspace */ - if ((status = H5Sclose(ref_dataspace_id)) < 0) { + if (H5Sclose(ref_dataspace_id) < 0) { fprintf(stderr , "Unable to close palette dataspace.\n"); return -1; } /* close everything */ - if ((status = H5Dclose(pal_id)) < 0) { + if (H5Dclose(pal_id) < 0) { fprintf(stderr , "Unable to close palette dataset. Aborting.\n"); return -1; } - if ((status = H5Sclose(dataspace_id)) < 0) { + if (H5Sclose(dataspace_id) < 0) { fprintf(stderr , "Unable to close palette dataspace. Aborting.\n"); return -1; } @@ -258,7 +245,7 @@ char *GIFFileName; /* write out the image */ /****** Ask Elena about VOIDP ******/ - if ((status = H5Dwrite(sub_image_id , H5T_NATIVE_UINT8 , H5S_ALL , H5S_ALL , H5P_DEFAULT , (void *)(gifImageDesc->Image))) < 0) { + if (H5Dwrite(sub_image_id , H5T_NATIVE_UINT8 , H5S_ALL , H5S_ALL , H5P_DEFAULT , (void *)(gifImageDesc->Image)) < 0) { fprintf(stderr , "Error writing image. Aborting... \n"); return -1; } @@ -332,19 +319,19 @@ char *GIFFileName; /* create the attribute */ attr_attr_id = H5Acreate(sub_image_id , "PALETTE" , H5T_STD_REF_OBJ , attr_dataspace_id , H5P_DEFAULT); - if ((status = H5Awrite(attr_attr_id , H5T_STD_REF_OBJ , &pal_ref)) < 0) { + if (H5Awrite(attr_attr_id , H5T_STD_REF_OBJ , &pal_ref) < 0) { fprintf(stderr , "Unable to write attribute. Aborting \n"); return -1; } /* close the attribute */ - if ((status = H5Aclose(attr_attr_id)) < 0) { + if (H5Aclose(attr_attr_id) < 0) { fprintf(stderr , "Unable to close CLASS IMAGE attribute. Aborting.\n"); return -1; } /* close the dataspace */ - if ((status = H5Sclose(attr_dataspace_id)) < 0) { + if (H5Sclose(attr_dataspace_id) < 0) { fprintf(stderr , "Unable to close attribute dataspace. Aborting \n"); return -1; } @@ -364,31 +351,31 @@ char *GIFFileName; /* create the attribute */ attr_attr_id = H5Acreate(sub_image_id , "IMAGE_MINMAXRANGE" , H5T_NATIVE_UINT8 , attr_dataspace_id , H5P_DEFAULT); - if ((status = H5Awrite(attr_attr_id , H5T_NATIVE_UINT8 , minmax)) < 0) { + if (H5Awrite(attr_attr_id , H5T_NATIVE_UINT8 , minmax) < 0) { fprintf(stderr , "Unable to write attribute. Aborting \n"); return -1; } /* close the attribute */ - if ((status = H5Aclose(attr_attr_id)) < 0) { + if (H5Aclose(attr_attr_id) < 0) { fprintf(stderr , "Unable to close CLASS IMAGE attribute. Aborting.\n"); return -1; } /* close the dataspace */ - if ((status = H5Sclose(attr_dataspace_id)) < 0) { + if (H5Sclose(attr_dataspace_id) < 0) { fprintf(stderr , "Unable to close attribute dataspace. Aborting \n"); return -1; } /* close everything */ - if ((status = H5Dclose(sub_image_id)) < 0) { + if (H5Dclose(sub_image_id) < 0) { fprintf(stderr , "Unable to close image dataset. Aborting \n"); return -1; } - if ((status = H5Sclose(dataspace_id)) < 0) { + if (H5Sclose(dataspace_id) < 0) { fprintf(stderr , "Unable to close image dataspace. Aborting \n"); return -1; } @@ -396,13 +383,13 @@ char *GIFFileName; } /* close the main image group */ - if ((status = H5Gclose(image_id)) < 0) { + if (H5Gclose(image_id) < 0) { fprintf(stderr , "Could not close the image group. Aborting...\n"); return -1; } /* close the H5 file */ - if ((status = H5Fclose(file_id)) < 0) { + if (H5Fclose(file_id) < 0) { fprintf(stderr , "Could not close HDF5 file. Aborting...\n"); return -1; } |