From b9ab8805bd66e5fc6dc74788435df455899eb661 Mon Sep 17 00:00:00 2001 From: malaterre Date: Fri, 23 Apr 2004 02:32:11 +0000 Subject: [PATCH] some cosmetic cleanup so that compilation : -W -Wall -Werror can pass. 1. I have added some unsigned where needed 2. Some function parameter not used -> (void) 3. In gdcmDicomDir.cxx, add GDCM_DICOMDIR_NONE case 4. g++ don't like character '\' in comment 5. #define jpeg_create_decompress jCreaDecompress this really need to be fixed 6. virtualize destructor of gdcmObject ... leakage 7. sscanf(g->first.c_str(),"%x",&gr_bid); this also really need to be fixed 8. gdcm/src/jpeg/libijg8/CMakeLists.txt, remove compression file (as we only do decompression, right ?) --- src/gdcmDicomDir.cxx | 6 ++++- src/gdcmDirList.h | 4 ++-- src/gdcmFile.cxx | 3 ++- src/gdcmHeaderEntry.cxx | 5 ++++- src/gdcmJpeg12.cxx | 2 +- src/gdcmJpeg2000.cxx | 2 ++ src/gdcmObject.h | 2 +- src/gdcmParsePixels.cxx | 40 ++++++++++++++++----------------- src/gdcmParser.cxx | 18 ++++++++------- src/gdcmRLE.cxx | 3 ++- src/gdcmUtil.cxx | 2 +- src/jpeg/libijg/CMakeLists.txt | 34 ++++++++++++++-------------- src/jpeg/libijg8/CMakeLists.txt | 34 ++++++++++++++-------------- 13 files changed, 84 insertions(+), 71 deletions(-) diff --git a/src/gdcmDicomDir.cxx b/src/gdcmDicomDir.cxx index 0ae78107..172a1a6f 100644 --- a/src/gdcmDicomDir.cxx +++ b/src/gdcmDicomDir.cxx @@ -642,6 +642,9 @@ void gdcmDicomDir::AddObjectToEnd(gdcmDicomDirType type,ListTag::iterator begin, case gdcmDicomDir::GDCM_DICOMDIR_IMAGE: AddDicomDirImageToEnd(begin,end); break; + case gdcmDicomDir::GDCM_DICOMDIR_NONE: + AddDicomDirImageToEnd(begin,end); //FIXME + break; } } @@ -929,7 +932,8 @@ void gdcmDicomDir::UpdateDirectoryRecordSequenceLength() { offset += 4; // delimiters don't have a value. } } - bool res=SetEntryLengthByNumber(offset, 0x0004, 0x1220); // Hope there is no dupps. + //bool res=SetEntryLengthByNumber(offset, 0x0004, 0x1220); // Hope there is no dupps. + SetEntryLengthByNumber(offset, 0x0004, 0x1220); // Hope there is no dupps. return; } diff --git a/src/gdcmDirList.h b/src/gdcmDirList.h index 33c8ab10..0ffb6c1e 100644 --- a/src/gdcmDirList.h +++ b/src/gdcmDirList.h @@ -21,9 +21,9 @@ public : std::string GetDirName(void); - /// Character \ + /// Character '\' static const char SEPARATOR_X; - /// Character / + /// Character '/' static const char SEPARATOR_WIN; /// depending on the O.S. static const std::string SEPARATOR; diff --git a/src/gdcmFile.cxx b/src/gdcmFile.cxx index 500f6f6b..769f3edb 100644 --- a/src/gdcmFile.cxx +++ b/src/gdcmFile.cxx @@ -254,7 +254,8 @@ void * gdcmFile::GetImageData (void) { * failure e.g. MaxSize is lower than necessary. */ size_t gdcmFile::GetImageDataIntoVector (void* destination, size_t MaxSize) { - size_t l = GetImageDataIntoVectorRaw (destination, MaxSize); + //size_t l = GetImageDataIntoVectorRaw (destination, MaxSize); + GetImageDataIntoVectorRaw (destination, MaxSize); PixelRead=0 ; // no PixelRaw if (!Header->HasLUT()) return lgrTotale; diff --git a/src/gdcmHeaderEntry.cxx b/src/gdcmHeaderEntry.cxx index 1b433881..eda099ce 100644 --- a/src/gdcmHeaderEntry.cxx +++ b/src/gdcmHeaderEntry.cxx @@ -124,7 +124,10 @@ void gdcmHeaderEntry::Print(std::ostream & os) { if (v == "4294967295") // to avoid troubles in convertion sprintf (st," x(ffffffff)"); else - sprintf(st," x(%x)",(unsigned long)atof(v.c_str())); + { + //sprintf(st," x(%x)",(unsigned long)atof(v.c_str())); + sprintf(st," x(%x)", atoi(v.c_str()));//FIXME + } s << st; } s << std::endl; diff --git a/src/gdcmJpeg12.cxx b/src/gdcmJpeg12.cxx index 29b6d928..e8b0b8b0 100644 --- a/src/gdcmJpeg12.cxx +++ b/src/gdcmJpeg12.cxx @@ -21,7 +21,7 @@ #define jpeg_read_header jReadHeader #define jpeg_read_scanlines jReadScanlines #define jpeg_finish_decompress jFinDecompress -#define jpeg_create_decompress jCreaDecompress +//#define jpeg_create_decompress jCreaDecompress //FIXME // ----------------- #define jpeg_std_error jStdError diff --git a/src/gdcmJpeg2000.cxx b/src/gdcmJpeg2000.cxx index 1c9c8e49..bbfed948 100644 --- a/src/gdcmJpeg2000.cxx +++ b/src/gdcmJpeg2000.cxx @@ -15,6 +15,8 @@ */ bool gdcmFile::gdcm_read_JPEG2000_file (FILE *fp,void * image_buffer) { + (void)fp; //FIXME + (void)image_buffer; //FIXME printf("Sorry JPEG 2000 File not yet taken into account\n"); return false; } diff --git a/src/gdcmObject.h b/src/gdcmObject.h index a7b0665b..7e842e00 100644 --- a/src/gdcmObject.h +++ b/src/gdcmObject.h @@ -61,7 +61,7 @@ protected: // constructor and destructor are protected to avoid end user to instanciate this class. gdcmObject(ListTag::iterator begin,ListTag::iterator end, TagHeaderEntryHT *ptagHT, ListTag *plistEntries); - ~gdcmObject(void); + virtual ~gdcmObject(void); void FillObject(std::list elemList); diff --git a/src/gdcmParsePixels.cxx b/src/gdcmParsePixels.cxx index c95b825f..241bd818 100644 --- a/src/gdcmParsePixels.cxx +++ b/src/gdcmParsePixels.cxx @@ -46,16 +46,16 @@ bool gdcmFile::ParsePixelData(void) { nb = atoi(str_nb.c_str() ); if (nb == 12) nb =16; } - int nBytes= nb/8; + //int nBytes= nb/8; //FIXME - int taille = Header->GetXSize() * Header->GetYSize() * Header->GetSamplesPerPixel(); + //int taille = Header->GetXSize() * Header->GetYSize() * Header->GetSamplesPerPixel(); printf ("Checking the Dicom-encapsulated Jpeg/RLE Pixels\n"); guint16 ItemTagGr,ItemTagEl; int ln; long ftellRes; - char * destination = NULL; + //char * destination = NULL; // -------------------- for Parsing : Position on begining of Jpeg/RLE Pixels @@ -70,13 +70,13 @@ bool gdcmFile::ParsePixelData(void) { ItemTagEl=Header->SwapShort(ItemTagEl); } printf ("at %x : ItemTag (should be fffe,e000): %04x,%04x\n", - ftellRes,ItemTagGr,ItemTagEl ); + (unsigned)ftellRes,ItemTagGr,ItemTagEl ); ftellRes=ftell(fp); fread(&ln,4,1,fp); if(Header->GetSwapCode()) ln=Header->SwapLong(ln); // Basic Offset Table Item Length - printf("at %x : Basic Offset Table Item Length (??) %d x(%08x)\n", - ftellRes,ln,ln); + printf("at %x : Basic Offset Table Item Length (\?\?) %d x(%08x)\n", + (unsigned)ftellRes,ln,ln); if (ln != 0) { // What is it used for ?? char * BasicOffsetTableItemValue= (char *)malloc(ln+1); @@ -96,7 +96,7 @@ bool gdcmFile::ParsePixelData(void) { ItemTagEl=Header->SwapShort(ItemTagEl); } printf ("at %x : ItemTag (should be fffe,e000 or e0dd): %04x,%04x\n", - ftellRes,ItemTagGr,ItemTagEl ); + (unsigned)ftellRes,ItemTagGr,ItemTagEl ); while ( ( ItemTagGr==0xfffe) && (ItemTagEl!=0xe0dd) ) { // Parse fragments @@ -105,7 +105,7 @@ bool gdcmFile::ParsePixelData(void) { if(Header->GetSwapCode()) ln=Header->SwapLong(ln); // length printf(" at %x : fragment length %d x(%08x)\n", - ftellRes, ln,ln); + (unsigned)ftellRes, ln,ln); // destination += taille * nBytes; // location in user's memory //printf (" Destination will be x(%x) = %d \n", @@ -123,7 +123,7 @@ bool gdcmFile::ParsePixelData(void) { ItemTagEl=Header->SwapShort(ItemTagEl); } printf ("at %x : ItemTag (should be fffe,e000 or e0dd): %04x,%04x\n", - ftellRes,ItemTagGr,ItemTagEl ); + (unsigned)ftellRes,ItemTagGr,ItemTagEl ); } } else { @@ -142,14 +142,14 @@ bool gdcmFile::ParsePixelData(void) { ItemTagEl=Header->SwapShort(ItemTagEl); } printf ("at %x : ItemTag (should be fffe,e000): %04x,%04x\n", - ftellRes,ItemTagGr,ItemTagEl ); + (unsigned)ftellRes,ItemTagGr,ItemTagEl ); // Item Length ftellRes=ftell(fp); fread(&ln,4,1,fp); if(Header->GetSwapCode()) ln=Header->SwapLong(ln); // Basic Offset Table Item Length - printf("at %x : Basic Offset Table Item Length (??) %d x(%08x)\n", - ftellRes,ln,ln); + printf("at %x : Basic Offset Table Item Length (\?\?) %d x(%08x)\n", + (unsigned)ftellRes,ln,ln); if (ln != 0) { // What is it used for ?? char * BasicOffsetTableItemValue= (char *)malloc(ln+1); @@ -169,7 +169,7 @@ bool gdcmFile::ParsePixelData(void) { ItemTagEl=Header->SwapShort(ItemTagEl); } printf ("at %x : ItemTag (should be fffe,e000 or e0dd): %04x,%04x\n", - ftellRes,ItemTagGr,ItemTagEl ); + (unsigned)ftellRes,ItemTagGr,ItemTagEl ); // while 'Sequence Delimiter Item' (fffe,e0dd) not found while ( ( ItemTagGr == 0xfffe) && (ItemTagEl != 0xe0dd) ) { @@ -179,7 +179,7 @@ bool gdcmFile::ParsePixelData(void) { if(Header->GetSwapCode()) fragmentLength=Header->SwapLong(fragmentLength); // length printf(" at %x : 'fragment' length %d x(%08x)\n", - ftellRes, fragmentLength,fragmentLength); + (unsigned)ftellRes, (unsigned)fragmentLength,(unsigned)fragmentLength); //------------------ scanning (not reading) fragment pixels @@ -194,17 +194,17 @@ bool gdcmFile::ParsePixelData(void) { if(Header->GetSwapCode()) RleSegmentOffsetTable[k]=Header->SwapLong(RleSegmentOffsetTable[k]); printf(" at : %x Offset Segment %d : %d (%x)\n", - ftellRes,k,RleSegmentOffsetTable[k], + (unsigned)ftellRes,k,RleSegmentOffsetTable[k], RleSegmentOffsetTable[k]); } if (nbRleSegments>1) { // skipping (not reading) RLE Segments - for(int k=1; k<=nbRleSegments-1; k++) { + for(unsigned int k=1; k<=nbRleSegments-1; k++) { RleSegmentLength[k]= RleSegmentOffsetTable[k+1] - RleSegmentOffsetTable[k]; ftellRes=ftell(fp); printf (" Segment %d : Length = %d x(%x) Start at %x\n", - k,RleSegmentLength[k],RleSegmentLength[k], ftellRes); + k,(unsigned)RleSegmentLength[k],(unsigned)RleSegmentLength[k], (unsigned)ftellRes); fseek(fp,RleSegmentLength[k],SEEK_CUR); } } @@ -212,8 +212,8 @@ bool gdcmFile::ParsePixelData(void) { - RleSegmentOffsetTable[nbRleSegments]; ftellRes=ftell(fp); printf (" Segment %d : Length = %d x(%x) Start at %x\n", - nbRleSegments,RleSegmentLength[nbRleSegments], - RleSegmentLength[nbRleSegments],ftellRes); + nbRleSegments,(unsigned)RleSegmentLength[nbRleSegments], + (unsigned)RleSegmentLength[nbRleSegments],(unsigned)ftellRes); fseek(fp,RleSegmentLength[nbRleSegments],SEEK_CUR); @@ -227,7 +227,7 @@ bool gdcmFile::ParsePixelData(void) { ItemTagEl=Header->SwapShort(ItemTagEl); } printf ("at %x : ItemTag (should be fffe,e000 or e0dd): %04x,%04x\n", - ftellRes,ItemTagGr,ItemTagEl ); + (unsigned)ftellRes,ItemTagGr,ItemTagEl ); } } return true; diff --git a/src/gdcmParser.cxx b/src/gdcmParser.cxx index c84cbb28..6cccb5a4 100644 --- a/src/gdcmParser.cxx +++ b/src/gdcmParser.cxx @@ -84,6 +84,7 @@ gdcmParser::gdcmParser(const char *inFilename, * @param exception_on_error */ gdcmParser::gdcmParser(bool exception_on_error) { + (void)exception_on_error; enableSequences=0; SetMaxSizeLoadEntry(MAX_SIZE_LOAD_ELEMENT_VALUE); @@ -751,7 +752,7 @@ void *gdcmParser::LoadEntryVoidArea(guint16 Group, guint16 Elem) return NULL; size_t o =(size_t)Element->GetOffset(); fseek(fp, o, SEEK_SET); - int l=Element->GetLength(); + size_t l=Element->GetLength(); void * a = malloc(l); if(!a) return NULL; @@ -979,7 +980,7 @@ void gdcmParser::UpdateGroupLength(bool SkipSequence, FileType type) { { // FIXME: g++ -Wall -Wstrict-prototypes reports on following line: // warning: unsigned int format, different type arg - sscanf(g->first.c_str(),"%x",&gr_bid); + sscanf(g->first.c_str(),"%x",&gr_bid); //FIXME tk = g->first + "|0000"; // generate the element full tag if ( tagHT.count(tk) == 0) // if element 0x0000 not found @@ -1070,6 +1071,7 @@ void gdcmParser::WriteEntryTagVRLength(gdcmHeaderEntry *tag, */ void gdcmParser::WriteEntryValue(gdcmHeaderEntry *tag, FILE *_fp,FileType type) { + (void)type; guint16 group = tag->GetGroup(); std::string vr = tag->GetVR(); guint32 lgr = tag->GetReadLength(); @@ -1092,7 +1094,7 @@ void gdcmParser::WriteEntryValue(gdcmHeaderEntry *tag, FILE *_fp,FileType type) if (vr == "US" || vr == "SS") { // some 'Short integer' fields may be mulivaluated - // each single value is separated from the next one by \ + // each single value is separated from the next one by '\' // we split the string and write each value as a short int std::vector tokens; tokens.erase(tokens.begin(),tokens.end()); // clean any previous value @@ -1107,7 +1109,7 @@ void gdcmParser::WriteEntryValue(gdcmHeaderEntry *tag, FILE *_fp,FileType type) return; } // some 'Integer' fields may be mulivaluated - // each single value is separated from the next one by \ + // each single value is separated from the next one by '\' // we split the string and write each value as an int if (vr == "UL" || vr == "SL") { @@ -1301,7 +1303,7 @@ guint16 gdcmParser::UnswapShort(guint16 a) { * @return false if file is not ACR-NEMA / DICOM */ bool gdcmParser::ParseHeader(bool exception_on_error) throw(gdcmFormatError) { - + (void)exception_on_error; rewind(fp); if (!CheckSwap()) return false; @@ -1503,7 +1505,7 @@ void gdcmParser::AddHeaderEntry(gdcmHeaderEntry *newHeaderEntry) { */ void gdcmParser::FindHeaderEntryLength (gdcmHeaderEntry *Entry) { guint16 element = Entry->GetElement(); - guint16 group = Entry->GetGroup(); + //guint16 group = Entry->GetGroup(); //FIXME std::string vr = Entry->GetVR(); guint16 length16; @@ -1737,7 +1739,7 @@ std::string gdcmParser::GetHeaderEntryValue(gdcmHeaderEntry *Entry) // When short integer(s) are expected, read and convert the following // n * 2 bytes properly i.e. as a multivaluated strings - // (each single value is separated fromthe next one by \ + // (each single value is separated fromthe next one by '\' // as usual for standard multivaluated filels // Elements with Value Multiplicity > 1 // contain a set of short integers (not a single one) @@ -1759,7 +1761,7 @@ std::string gdcmParser::GetHeaderEntryValue(gdcmHeaderEntry *Entry) // When integer(s) are expected, read and convert the following // n * 4 bytes properly i.e. as a multivaluated strings - // (each single value is separated fromthe next one by \ + // (each single value is separated fromthe next one by '\' // as usual for standard multivaluated filels // Elements with Value Multiplicity > 1 // contain a set of integers (not a single one) diff --git a/src/gdcmRLE.cxx b/src/gdcmRLE.cxx index 2f38ae17..83a0c281 100644 --- a/src/gdcmRLE.cxx +++ b/src/gdcmRLE.cxx @@ -79,7 +79,7 @@ bool gdcmFile::gdcm_read_RLE_file (FILE *fp,void * image_buffer) { } if (nbRleSegments>1) { - for(int k=1; k<=nbRleSegments-1; k++) { // reading RLE Segments + for(unsigned int k=1; k<=nbRleSegments-1; k++) { // reading RLE Segments RleSegmentLength[k]=RleSegmentOffsetTable[k+1]-RleSegmentOffsetTable[k]; ftellRes=ftell(fp); fragmentBegining=ftell(fp); @@ -137,6 +137,7 @@ bool gdcmFile::gdcm_read_RLE_file (FILE *fp,void * image_buffer) { // RLE LossLess Fragment int gdcmFile::gdcm_read_RLE_fragment(char **areaToRead, long lengthToDecode, long uncompressedSegmentSize, FILE *fp) { + (void)lengthToDecode; //FIXME long ftellRes; int count; long numberOfOutputBytes=0; diff --git a/src/gdcmUtil.cxx b/src/gdcmUtil.cxx index 105ef232..c6a9d036 100644 --- a/src/gdcmUtil.cxx +++ b/src/gdcmUtil.cxx @@ -47,7 +47,7 @@ void Tokenize (const std::string& str, std::string CreateCleanString(std::string s) { std::string str=s; - for(int i=0;i