summaryrefslogtreecommitdiff
path: root/core/src/fxcodec
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-12-14 18:29:28 -0800
committerLei Zhang <thestig@chromium.org>2015-12-14 18:29:28 -0800
commite385244f8cd6ae376f6b3cf1265a0795d5d30eff (patch)
tree4bdd7c459f167ee56ae35f3b87222c2557f501f8 /core/src/fxcodec
parente3c7c2b54348da4a6939f6672f6c6bff126815a7 (diff)
downloadpdfium-e385244f8cd6ae376f6b3cf1265a0795d5d30eff.tar.xz
Get rid of most instance of 'foo == NULL'
R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1520063002 .
Diffstat (limited to 'core/src/fxcodec')
-rw-r--r--core/src/fxcodec/codec/fx_codec.cpp2
-rw-r--r--core/src/fxcodec/codec/fx_codec_flate.cpp4
-rw-r--r--core/src/fxcodec/codec/fx_codec_icc.cpp24
-rw-r--r--core/src/fxcodec/codec/fx_codec_jpeg.cpp9
-rw-r--r--core/src/fxcodec/codec/fx_codec_jpx_opj.cpp8
5 files changed, 23 insertions, 24 deletions
diff --git a/core/src/fxcodec/codec/fx_codec.cpp b/core/src/fxcodec/codec/fx_codec.cpp
index ad6fc95c90..6998114f83 100644
--- a/core/src/fxcodec/codec/fx_codec.cpp
+++ b/core/src/fxcodec/codec/fx_codec.cpp
@@ -168,7 +168,7 @@ extern "C" double FXstrtod(const char* nptr, char** endptr) {
const char* exp_ptr = NULL;
int e_number = 0, e_signal = 0, e_point = 0, is_negative = 0;
int exp_ret = 0, exp_sig = 1, fra_ret = 0, fra_count = 0, fra_base = 1;
- if (nptr == NULL) {
+ if (!nptr) {
return 0.0;
}
for (;; ptr++) {
diff --git a/core/src/fxcodec/codec/fx_codec_flate.cpp b/core/src/fxcodec/codec/fx_codec_flate.cpp
index f9959589b3..b293781318 100644
--- a/core/src/fxcodec/codec/fx_codec_flate.cpp
+++ b/core/src/fxcodec/codec/fx_codec_flate.cpp
@@ -34,7 +34,7 @@ static void FPDFAPI_FlateCompress(unsigned char* dest_buf,
void* FPDFAPI_FlateInit(void* (*alloc_func)(void*, unsigned int, unsigned int),
void (*free_func)(void*, void*)) {
z_stream* p = (z_stream*)alloc_func(0, 1, sizeof(z_stream));
- if (p == NULL) {
+ if (!p) {
return NULL;
}
FXSYS_memset(p, 0, sizeof(z_stream));
@@ -835,7 +835,7 @@ FX_BOOL CCodec_FlateScanlineDecoder::v_Rewind() {
FPDFAPI_FlateEnd(m_pFlate);
}
m_pFlate = FPDFAPI_FlateInit(my_alloc_func, my_free_func);
- if (m_pFlate == NULL) {
+ if (!m_pFlate) {
return FALSE;
}
FPDFAPI_FlateInput(m_pFlate, m_SrcBuf, m_SrcSize);
diff --git a/core/src/fxcodec/codec/fx_codec_icc.cpp b/core/src/fxcodec/codec/fx_codec_icc.cpp
index 862872010b..7ae59a6510 100644
--- a/core/src/fxcodec/codec/fx_codec_icc.cpp
+++ b/core/src/fxcodec/codec/fx_codec_icc.cpp
@@ -102,16 +102,16 @@ void* IccLib_CreateTransform(const unsigned char* pSrcProfileData,
CLcmsCmm* pCmm = NULL;
nSrcComponents = 0;
srcProfile = cmsOpenProfileFromMem((void*)pSrcProfileData, dwSrcProfileSize);
- if (srcProfile == NULL) {
+ if (!srcProfile) {
return NULL;
}
- if (pDstProfileData == NULL && dwDstProfileSize == 0 && nDstComponents == 3) {
+ if (!pDstProfileData && dwDstProfileSize == 0 && nDstComponents == 3) {
dstProfile = cmsCreate_sRGBProfile();
} else {
dstProfile =
cmsOpenProfileFromMem((void*)pDstProfileData, dwDstProfileSize);
}
- if (dstProfile == NULL) {
+ if (!dstProfile) {
cmsCloseProfile(srcProfile);
return NULL;
}
@@ -153,7 +153,7 @@ void* IccLib_CreateTransform(const unsigned char* pSrcProfileData,
default:
break;
}
- if (hTransform == NULL) {
+ if (!hTransform) {
cmsCloseProfile(srcProfile);
cmsCloseProfile(dstProfile);
return NULL;
@@ -176,7 +176,7 @@ void* IccLib_CreateTransform_sRGB(const unsigned char* pProfileData,
0, 3, intent, dwSrcFormat);
}
void IccLib_DestroyTransform(void* pTransform) {
- if (pTransform == NULL) {
+ if (!pTransform) {
return;
}
cmsDeleteTransform(((CLcmsCmm*)pTransform)->m_hTransform);
@@ -186,7 +186,7 @@ void IccLib_Translate(void* pTransform,
FX_DWORD nSrcComponents,
FX_FLOAT* pSrcValues,
FX_FLOAT* pDestValues) {
- if (pTransform == NULL) {
+ if (!pTransform) {
return;
}
CLcmsCmm* p = (CLcmsCmm*)pTransform;
@@ -242,7 +242,7 @@ void* CreateProfile_Gray(double gamma) {
return NULL;
}
cmsToneCurve* curve = cmsBuildGamma(NULL, gamma);
- if (curve == NULL) {
+ if (!curve) {
return NULL;
}
void* profile = cmsCreateGrayProfile(D50, curve);
@@ -250,7 +250,7 @@ void* CreateProfile_Gray(double gamma) {
return profile;
}
ICodec_IccModule::IccCS GetProfileCSFromHandle(void* pProfile) {
- if (pProfile == NULL) {
+ if (!pProfile) {
return ICodec_IccModule::IccCS_Unknown;
}
switch (cmsGetColorSpace(pProfile)) {
@@ -286,7 +286,7 @@ ICodec_IccModule::IccCS CCodec_IccModule::GetProfileCS(
ICodec_IccModule::IccCS cs;
cmsHPROFILE hProfile =
cmsOpenProfileFromMem((void*)pProfileData, dwProfileSize);
- if (hProfile == NULL) {
+ if (!hProfile) {
return IccCS_Unknown;
}
cs = GetProfileCSFromHandle(hProfile);
@@ -296,7 +296,7 @@ ICodec_IccModule::IccCS CCodec_IccModule::GetProfileCS(
return cs;
}
ICodec_IccModule::IccCS CCodec_IccModule::GetProfileCS(IFX_FileRead* pFile) {
- if (pFile == NULL) {
+ if (!pFile) {
return IccCS_Unknown;
}
ICodec_IccModule::IccCS cs;
@@ -476,11 +476,11 @@ void* CCodec_IccModule::CreateTransform(
ASSERT(pInputParam && pOutputParam);
CFX_ByteStringKey key;
void* pInputProfile = CreateProfile(pInputParam, Icc_CLASS_INPUT, &key);
- if (pInputProfile == NULL) {
+ if (!pInputProfile) {
return NULL;
}
void* pOutputProfile = CreateProfile(pOutputParam, Icc_CLASS_OUTPUT, &key);
- if (pOutputProfile == NULL) {
+ if (!pOutputProfile) {
return NULL;
}
FX_DWORD dwInputProfileType =
diff --git a/core/src/fxcodec/codec/fx_codec_jpeg.cpp b/core/src/fxcodec/codec/fx_codec_jpeg.cpp
index 730872363c..043964f254 100644
--- a/core/src/fxcodec/codec/fx_codec_jpeg.cpp
+++ b/core/src/fxcodec/codec/fx_codec_jpeg.cpp
@@ -82,7 +82,7 @@ static void _error_do_nothing2(j_common_ptr cinfo, char*) {}
static FX_BOOL _JpegEmbedIccProfile(j_compress_ptr cinfo,
const uint8_t* icc_buf_ptr,
FX_DWORD icc_length) {
- if (icc_buf_ptr == NULL || icc_length == 0) {
+ if (!icc_buf_ptr || icc_length == 0) {
return FALSE;
}
FX_DWORD icc_segment_size = (JPEG_MARKER_MAXSIZE - 2 - JPEG_OVERHEAD_LEN);
@@ -501,7 +501,7 @@ ICodec_ScanlineDecoder* CCodec_JpegModule::CreateDecoder(
int height,
int nComps,
FX_BOOL ColorTransform) {
- if (src_buf == NULL || src_size == 0) {
+ if (!src_buf || src_size == 0) {
return NULL;
}
CCodec_JpegDecoder* pDecoder = new CCodec_JpegDecoder;
@@ -531,10 +531,9 @@ FX_BOOL CCodec_JpegModule::Encode(const CFX_DIBSource* pSource,
int quality,
const uint8_t* icc_buf,
FX_DWORD icc_length) {
- if (pSource->GetBPP() < 8 || pSource->GetPalette()) {
- ASSERT(pSource->GetBPP() >= 8 && pSource->GetPalette() == NULL);
+ if (pSource->GetBPP() < 8 || pSource->GetPalette())
return FALSE;
- }
+
_JpegEncode(pSource, dest_buf, dest_size, quality, icc_buf, icc_length);
return TRUE;
}
diff --git a/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp b/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp
index cf017ca17a..21c1e441f0 100644
--- a/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp
+++ b/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp
@@ -438,7 +438,7 @@ void color_apply_icc_profile(opj_image_t* image) {
int max;
cmsHPROFILE in_prof =
cmsOpenProfileFromMem(image->icc_profile_buf, image->icc_profile_len);
- if (in_prof == NULL) {
+ if (!in_prof) {
return;
}
cmsColorSpaceSignature out_space = cmsGetColorSpace(in_prof);
@@ -479,7 +479,7 @@ void color_apply_icc_profile(opj_image_t* image) {
cmsCreateTransform(in_prof, in_type, out_prof, out_type, intent, 0);
cmsCloseProfile(in_prof);
cmsCloseProfile(out_prof);
- if (transform == NULL) {
+ if (!transform) {
image->color_space = oldspace;
return;
}
@@ -597,7 +597,7 @@ void color_apply_conversion(opj_image_t* image) {
INTENT_PERCEPTUAL, 0);
cmsCloseProfile(in);
cmsCloseProfile(out);
- if (transform == NULL) {
+ if (!transform) {
return;
}
prec0 = (double)image->comps[0].prec;
@@ -708,7 +708,7 @@ FX_BOOL CJPX_Decoder::Init(const unsigned char* src_data, FX_DWORD src_size) {
DecodeData srcData(const_cast<unsigned char*>(src_data), src_size);
l_stream = fx_opj_stream_create_memory_stream(&srcData,
OPJ_J2K_STREAM_CHUNK_SIZE, 1);
- if (l_stream == NULL) {
+ if (!l_stream) {
return FALSE;
}
opj_dparameters_t parameters;