@@ -75,7 +75,7 @@ bool LLImageDimensionsInfo::load(const std::string& src_filename,U32 codec)
75
75
bool LLImageDimensionsInfo::getImageDimensionsBmp ()
76
76
{
77
77
// Make sure the file is long enough.
78
- const S32 DATA_LEN = 26 ; // BMP header (14) + DIB header size (4) + width (4) + height (4)
78
+ constexpr S32 DATA_LEN = 26 ; // BMP header (14) + DIB header size (4) + width (4) + height (4)
79
79
if (!checkFileLength (DATA_LEN))
80
80
{
81
81
LL_WARNS () << " Premature end of file" << LL_ENDL;
@@ -105,7 +105,7 @@ bool LLImageDimensionsInfo::getImageDimensionsBmp()
105
105
106
106
bool LLImageDimensionsInfo::getImageDimensionsTga ()
107
107
{
108
- const S32 TGA_FILE_HEADER_SIZE = 12 ;
108
+ constexpr S32 TGA_FILE_HEADER_SIZE = 12 ;
109
109
110
110
// Make sure the file is long enough.
111
111
if (!checkFileLength (TGA_FILE_HEADER_SIZE + 1 /* width */ + 1 /* height */ ))
@@ -124,7 +124,7 @@ bool LLImageDimensionsInfo::getImageDimensionsTga()
124
124
125
125
bool LLImageDimensionsInfo::getImageDimensionsPng ()
126
126
{
127
- const S32 PNG_MAGIC_SIZE = 8 ;
127
+ constexpr S32 PNG_MAGIC_SIZE = 8 ;
128
128
129
129
// Make sure the file is long enough.
130
130
if (!checkFileLength (PNG_MAGIC_SIZE + 8 + sizeof (S32) * 2 /* width, height */ ))
@@ -134,7 +134,7 @@ bool LLImageDimensionsInfo::getImageDimensionsPng()
134
134
}
135
135
136
136
// Read PNG signature.
137
- const U8 png_magic[PNG_MAGIC_SIZE] = {0x89 , 0x50 , 0x4E , 0x47 , 0x0D , 0x0A , 0x1A , 0x0A };
137
+ constexpr U8 png_magic[PNG_MAGIC_SIZE] = {0x89 , 0x50 , 0x4E , 0x47 , 0x0D , 0x0A , 0x1A , 0x0A };
138
138
U8 signature[PNG_MAGIC_SIZE];
139
139
mInfile .read ((void *)signature, PNG_MAGIC_SIZE);
140
140
@@ -166,34 +166,36 @@ bool LLImageDimensionsInfo::getImageDimensionsJpeg()
166
166
{
167
167
sJpegErrorEncountered = false ;
168
168
clean ();
169
- FILE * fp = LLFile::fopen (mSrcFilename , " rb" );
170
- if (fp == NULL )
169
+ FILE* fp = LLFile::fopen (mSrcFilename , " rb" );
170
+ if (!fp )
171
171
{
172
172
setLastError (" Unable to open file for reading" , mSrcFilename );
173
173
return false ;
174
174
}
175
175
176
176
/* Make sure this is a JPEG file. */
177
- const size_t JPEG_MAGIC_SIZE = 2 ;
178
- const U8 jpeg_magic[JPEG_MAGIC_SIZE] = {0xFF , 0xD8 };
177
+ constexpr size_t JPEG_MAGIC_SIZE = 2 ;
178
+ constexpr U8 jpeg_magic[JPEG_MAGIC_SIZE] = {0xFF , 0xD8 };
179
179
U8 signature[JPEG_MAGIC_SIZE];
180
180
181
181
if (fread (signature, sizeof (signature), 1 , fp) != 1 )
182
182
{
183
183
LL_WARNS () << " Premature end of file" << LL_ENDL;
184
+ fclose (fp);
184
185
return false ;
185
186
}
186
187
if (memcmp (signature, jpeg_magic, JPEG_MAGIC_SIZE) != 0 )
187
188
{
188
189
LL_WARNS () << " Not a JPEG" << LL_ENDL;
189
190
mWarning = " texture_load_format_error" ;
191
+ fclose (fp);
190
192
return false ;
191
193
}
192
194
fseek (fp, 0 , SEEK_SET); // go back to start of the file
193
195
194
196
/* Init jpeg */
195
197
jpeg_error_mgr jerr;
196
- jpeg_decompress_struct cinfo;
198
+ jpeg_decompress_struct cinfo{} ;
197
199
cinfo.err = jpeg_std_error (&jerr);
198
200
// Call our function instead of exit() if Libjpeg encounters an error.
199
201
// This is done to avoid crash in this case (STORM-472).
0 commit comments