Skip to content

Commit 932fe52

Browse files
jdv_cpjdv_cp
authored andcommitted
Warning free build on Ubuntu x64 -Wextra, -Wall -pedantic
1 parent ac49fd9 commit 932fe52

File tree

9 files changed

+66
-66
lines changed

9 files changed

+66
-66
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ IF(NOT CMAKE_BUILD_TYPE)
77
# The following compiler option are only meant for GCC:
88
IF(CMAKE_COMPILER_IS_GNUCC)
99
# the following is optimization micrmanagement that made better code for x86
10-
# SET(CMAKE_CXX_FLAGS "-D NDEBUG -O3 -fvisibility=hidden -fomit-frame-pointer -momit-leaf-frame-pointer -fweb -ftracer" )
10+
# SET(CMAKE_CXX_FLAGS "-D NDEBUG -O3 -Wall -Wextra -pedantic -fvisibility=hidden -fomit-frame-pointer -momit-leaf-frame-pointer -fweb -ftracer" )
1111
SET(CMAKE_CXX_FLAGS "-D NDEBUG -O3" )
1212
ENDIF(CMAKE_COMPILER_IS_GNUCC)
1313
ENDIF(NOT CMAKE_BUILD_TYPE)
@@ -18,6 +18,6 @@ SET(BUILD_SHARED_LIBS ${charls_BUILD_SHARED_LIBS})
1818
add_library(CharLS header.cpp interface.cpp jpegls.cpp )
1919

2020

21-
add_executable(charlstest test/main.cpp test/time.cpp test/util.cpp test/bitstreamdamage.cpp test/compliance.cpp test/performance.cpp)
21+
add_executable(charlstest test/main.cpp test/time.cpp test/util.cpp test/bitstreamdamage.cpp test/compliance.cpp test/performance.cpp test/dicomsamples.cpp)
2222
target_link_libraries (charlstest CharLS)
2323

CharLS.vcproj

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
ModuleDefinitionFile="charls.def"
8080
GenerateDebugInformation="true"
8181
ProgramDatabaseFile="$(OutDir)/jpegls.pdb"
82-
SubSystem="2"
82+
SubSystem="1"
8383
OptimizeForWindows98="0"
8484
RandomizedBaseAddress="1"
8585
DataExecutionPrevention="0"
@@ -109,14 +109,15 @@
109109
/>
110110
</Configuration>
111111
<Configuration
112-
Name="Debug|x64"
113-
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
114-
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
112+
Name="Release|Win32"
113+
OutputDirectory="Release"
114+
IntermediateDirectory="Release"
115115
ConfigurationType="2"
116116
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC70.vsprops"
117117
UseOfMFC="0"
118118
UseOfATL="0"
119119
CharacterSet="2"
120+
WholeProgramOptimization="1"
120121
>
121122
<Tool
122123
Name="VCPreBuildEventTool"
@@ -132,27 +133,32 @@
132133
/>
133134
<Tool
134135
Name="VCMIDLTool"
135-
TargetEnvironment="3"
136136
/>
137137
<Tool
138138
Name="VCCLCompilerTool"
139-
Optimization="0"
140-
InlineFunctionExpansion="1"
141-
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;JPEGLS_EXPORTS"
142-
MinimalRebuild="true"
143-
BasicRuntimeChecks="3"
144-
SmallerTypeCheck="false"
145-
RuntimeLibrary="3"
139+
Optimization="2"
140+
InlineFunctionExpansion="2"
141+
EnableIntrinsicFunctions="true"
142+
FavorSizeOrSpeed="1"
143+
OmitFramePointers="true"
144+
EnableFiberSafeOptimizations="true"
145+
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;JPEGLS_EXPORTS"
146+
StringPooling="true"
147+
ExceptionHandling="1"
148+
BasicRuntimeChecks="0"
149+
RuntimeLibrary="0"
150+
StructMemberAlignment="0"
146151
BufferSecurityCheck="true"
152+
EnableFunctionLevelLinking="false"
153+
EnableEnhancedInstructionSet="0"
147154
DisableLanguageExtensions="true"
148155
ForceConformanceInForLoopScope="true"
149156
RuntimeTypeInfo="true"
150157
UsePrecompiledHeader="0"
151158
WarningLevel="4"
152-
WarnAsError="true"
153159
Detect64BitPortabilityProblems="false"
154160
DebugInformationFormat="3"
155-
CompileAs="2"
161+
CallingConvention="0"
156162
/>
157163
<Tool
158164
Name="VCManagedResourceCompilerTool"
@@ -166,16 +172,17 @@
166172
<Tool
167173
Name="VCLinkerTool"
168174
OutputFile="$(OutDir)/charls.dll"
169-
LinkIncremental="2"
175+
LinkIncremental="1"
170176
ModuleDefinitionFile="charls.def"
171177
GenerateDebugInformation="true"
172-
ProgramDatabaseFile="$(OutDir)/jpegls.pdb"
173178
SubSystem="2"
179+
OptimizeReferences="2"
180+
EnableCOMDATFolding="2"
174181
OptimizeForWindows98="0"
175182
RandomizedBaseAddress="1"
176183
DataExecutionPrevention="0"
177184
ImportLibrary="$(OutDir)/CharLS.lib"
178-
TargetMachine="17"
185+
TargetMachine="1"
179186
/>
180187
<Tool
181188
Name="VCALinkTool"
@@ -200,15 +207,14 @@
200207
/>
201208
</Configuration>
202209
<Configuration
203-
Name="Release|Win32"
204-
OutputDirectory="Release"
205-
IntermediateDirectory="Release"
210+
Name="Debug|x64"
211+
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
212+
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
206213
ConfigurationType="2"
207214
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC70.vsprops"
208215
UseOfMFC="0"
209216
UseOfATL="0"
210217
CharacterSet="2"
211-
WholeProgramOptimization="1"
212218
>
213219
<Tool
214220
Name="VCPreBuildEventTool"
@@ -224,32 +230,27 @@
224230
/>
225231
<Tool
226232
Name="VCMIDLTool"
233+
TargetEnvironment="3"
227234
/>
228235
<Tool
229236
Name="VCCLCompilerTool"
230-
Optimization="2"
231-
InlineFunctionExpansion="2"
232-
EnableIntrinsicFunctions="true"
233-
FavorSizeOrSpeed="1"
234-
OmitFramePointers="true"
235-
EnableFiberSafeOptimizations="true"
236-
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;JPEGLS_EXPORTS"
237-
StringPooling="true"
238-
ExceptionHandling="1"
239-
BasicRuntimeChecks="0"
240-
RuntimeLibrary="0"
241-
StructMemberAlignment="0"
237+
Optimization="0"
238+
InlineFunctionExpansion="1"
239+
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;JPEGLS_EXPORTS"
240+
MinimalRebuild="true"
241+
BasicRuntimeChecks="3"
242+
SmallerTypeCheck="false"
243+
RuntimeLibrary="3"
242244
BufferSecurityCheck="true"
243-
EnableFunctionLevelLinking="false"
244-
EnableEnhancedInstructionSet="0"
245245
DisableLanguageExtensions="true"
246246
ForceConformanceInForLoopScope="true"
247247
RuntimeTypeInfo="true"
248248
UsePrecompiledHeader="0"
249249
WarningLevel="4"
250+
WarnAsError="true"
250251
Detect64BitPortabilityProblems="false"
251252
DebugInformationFormat="3"
252-
CallingConvention="0"
253+
CompileAs="2"
253254
/>
254255
<Tool
255256
Name="VCManagedResourceCompilerTool"
@@ -263,17 +264,16 @@
263264
<Tool
264265
Name="VCLinkerTool"
265266
OutputFile="$(OutDir)/charls.dll"
266-
LinkIncremental="1"
267+
LinkIncremental="2"
267268
ModuleDefinitionFile="charls.def"
268269
GenerateDebugInformation="true"
270+
ProgramDatabaseFile="$(OutDir)/jpegls.pdb"
269271
SubSystem="2"
270-
OptimizeReferences="2"
271-
EnableCOMDATFolding="2"
272272
OptimizeForWindows98="0"
273273
RandomizedBaseAddress="1"
274274
DataExecutionPrevention="0"
275275
ImportLibrary="$(OutDir)/CharLS.lib"
276-
TargetMachine="1"
276+
TargetMachine="17"
277277
/>
278278
<Tool
279279
Name="VCALinkTool"
@@ -427,24 +427,24 @@
427427
/>
428428
</FileConfiguration>
429429
<FileConfiguration
430-
Name="Debug|x64"
430+
Name="Release|Win32"
431431
>
432432
<Tool
433433
Name="VCCLCompilerTool"
434+
Optimization="3"
434435
EnableIntrinsicFunctions="true"
436+
FavorSizeOrSpeed="1"
437+
BasicRuntimeChecks="0"
438+
BufferSecurityCheck="false"
439+
EnableFunctionLevelLinking="false"
435440
/>
436441
</FileConfiguration>
437442
<FileConfiguration
438-
Name="Release|Win32"
443+
Name="Debug|x64"
439444
>
440445
<Tool
441446
Name="VCCLCompilerTool"
442-
Optimization="3"
443447
EnableIntrinsicFunctions="true"
444-
FavorSizeOrSpeed="1"
445-
BasicRuntimeChecks="0"
446-
BufferSecurityCheck="false"
447-
EnableFunctionLevelLinking="false"
448448
/>
449449
</FileConfiguration>
450450
<FileConfiguration

header.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ void push_back(std::vector<BYTE>& vec, USHORT value)
9898
//
9999
JpegSegment* CreateMarkerStartOfFrame(Size size, LONG bitsPerSample, LONG ccomp)
100100
{
101+
101102
std::vector<BYTE> vec;
102103
vec.push_back(static_cast<BYTE>(bitsPerSample));
103104
push_back(vec, static_cast<USHORT>(size.cy));
@@ -197,7 +198,7 @@ size_t JLSOutputStream::Write(BYTE* pdata, size_t cbyteLength)
197198

198199

199200

200-
JLSInputStream::JLSInputStream(const BYTE* pdata, LONG cbyteLength) :
201+
JLSInputStream::JLSInputStream(const BYTE* pdata, size_t cbyteLength) :
201202
_pdata(pdata),
202203
_cbyteOffset(0),
203204
_cbyteLength(cbyteLength),
@@ -210,7 +211,7 @@ JLSInputStream::JLSInputStream(const BYTE* pdata, LONG cbyteLength) :
210211
//
211212
// Read()
212213
//
213-
void JLSInputStream::Read(void* pvoid, LONG cbyteAvailable)
214+
void JLSInputStream::Read(void* pvoid, size_t cbyteAvailable)
214215
{
215216
ReadHeader();
216217

@@ -228,7 +229,7 @@ void JLSInputStream::Read(void* pvoid, LONG cbyteAvailable)
228229
//
229230
// ReadPixels()
230231
//
231-
void JLSInputStream::ReadPixels(void* pvoid, LONG cbyteAvailable)
232+
void JLSInputStream::ReadPixels(void* pvoid, size_t cbyteAvailable)
232233
{
233234

234235
if (_rect.Width <= 0)
@@ -239,7 +240,7 @@ void JLSInputStream::ReadPixels(void* pvoid, LONG cbyteAvailable)
239240

240241
int64_t cbytePlane = (int64_t)(_rect.Width) * _rect.Height * ((_info.bitspersample + 7)/8);
241242

242-
if (cbyteAvailable < cbytePlane * _info.components)
243+
if (int64_t(cbyteAvailable) < cbytePlane * _info.components)
243244
throw JlsException(UncompressedBufferTooSmall);
244245

245246
int scancount = _info.ilv == ILV_NONE ? _info.components : 1;

scan.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ size_t JlsCodec<TRAITS,STRATEGY>::DecodeScan(void* rawData, const JlsRect& rect,
844844

845845
BYTE rgbyte[20];
846846

847-
LONG readBytes = 0;
847+
size_t readBytes = 0;
848848
::memcpy(rgbyte, compressedBytes, 4);
849849
readBytes += 4;
850850

streams.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ struct Presets : public JlsCustomParameters
118118
class JLSInputStream
119119
{
120120
public:
121-
JLSInputStream(const BYTE* pdata, LONG cbyteLength);
121+
JLSInputStream(const BYTE* pdata, size_t cbyteLength);
122122

123123
size_t GetBytesRead()
124124
{ return _cbyteOffset; }
@@ -129,7 +129,7 @@ class JLSInputStream
129129
const JlsCustomParameters& GetCustomPreset() const
130130
{ return _info.custom; }
131131

132-
void Read(void* pvoid, LONG cbyteAvailable);
132+
void Read(void* pvoid, size_t cbyteAvailable);
133133
void ReadHeader();
134134

135135
void EnableCompare(bool bCompare)
@@ -140,7 +140,7 @@ class JLSInputStream
140140
void SetRect(JlsRect rect) { _rect = rect; }
141141

142142
private:
143-
void ReadPixels(void* pvoid, LONG cbyteAvailable);
143+
void ReadPixels(void* pvoid, size_t cbyteAvailable);
144144
void ReadScan(void*);
145145
void ReadStartOfScan();
146146
void ReadPresetParameters();

test/compliance.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44

55

66
#include "config.h"
7-
#include <iostream>
8-
#include <vector>
97

108
#include "../interface.h"
119
#include "../util.h"
1210
#include "../streams.h"
1311

12+
#include <iostream>
13+
#include <vector>
14+
1415
#include "util.h"
1516

1617

test/dicomsamples.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ int findstring(std::vector<BYTE>& container, BYTE* bytesToFind, unsigned int byt
2828
#define COUNT(x) (sizeof(x)/sizeof(x[0]))
2929

3030

31-
void TestDicomSampleImage(char* name)
31+
void TestDicomSampleImage(const char* name)
3232
{
3333
std::vector<BYTE> data;
3434
bool success = ReadFile(name, &data, 9);
3535

3636
ASSERT(success);
3737

38-
BYTE pixeldataStart[] = { 0x00, 0x00, 0x01, 0x00, 0xFF, 0xD8, 0xFF, 0xF7 };
38+
BYTE pixeldataStart[] = { 0x00, 0x00, 0x01, 0x00, 0xFF, 0xD8, 0xFF, 0xF7 };
3939

4040
int offset = findstring(data, pixeldataStart, COUNT(pixeldataStart));
4141

test/main.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,7 @@ int main(int argc, char* argv[])
248248
continue;
249249
}
250250

251-
printf("Option not understood: ");
252-
printf(argv[i]);
253-
printf("\r\n");
251+
printf("Option not understood: %s\r\n", argv[i]);
254252
break;
255253

256254
}

test/util.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ bool ReadFile(SZC strName, std::vector<BYTE>* pvec, int ioffs, int bytes)
5959

6060
fseek(pfile, ioffs, SEEK_SET);
6161
pvec->resize(bytes);
62-
fread(&(*pvec)[0],1, pvec->size(), pfile);
62+
size_t bytesRead = fread(&(*pvec)[0],1, pvec->size(), pfile);
6363
fclose(pfile);
64-
return true;
64+
return bytesRead == pvec->size();
6565
}
6666

6767

0 commit comments

Comments
 (0)