Skip to content

Commit f929ab0

Browse files
GabrielYYZDonDiego
authored andcommitted
cosmetics: Write NULL pointer equality checks more compactly
Signed-off-by: Diego Biurrun <[email protected]>
1 parent efd26be commit f929ab0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+95
-97
lines changed

avconv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1363,7 +1363,7 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt)
13631363
if (ist->next_dts == AV_NOPTS_VALUE)
13641364
ist->next_dts = ist->last_dts;
13651365

1366-
if (pkt == NULL) {
1366+
if (!pkt) {
13671367
/* EOF handling */
13681368
av_init_packet(&avpkt);
13691369
avpkt.data = NULL;

avconv_opt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ static void assert_file_overwrite(const char *filename)
587587
}
588588

589589
if (!file_overwrite &&
590-
(strchr(filename, ':') == NULL || filename[1] == ':' ||
590+
(!strchr(filename, ':') || filename[1] == ':' ||
591591
av_strstart(filename, "file:", NULL))) {
592592
if (avio_check(filename, 0) == 0) {
593593
if (!using_stdin && !file_skip) {

avplay.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1388,7 +1388,7 @@ static int queue_picture(VideoState *is, AVFrame *src_frame, double pts, int64_t
13881388
is->img_convert_ctx = sws_getCachedContext(is->img_convert_ctx,
13891389
vp->width, vp->height, vp->pix_fmt, vp->width, vp->height,
13901390
dst_pix_fmt, sws_flags, NULL, NULL, NULL);
1391-
if (is->img_convert_ctx == NULL) {
1391+
if (!is->img_convert_ctx) {
13921392
fprintf(stderr, "Cannot initialize the conversion context\n");
13931393
exit(1);
13941394
}

cmdutils.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ static void prepare_app_arguments(int *argc_ptr, char ***argv_ptr)
225225

226226
win32_argv_utf8 = av_mallocz(sizeof(char *) * (win32_argc + 1) + buffsize);
227227
argstr_flat = (char *)win32_argv_utf8 + sizeof(char *) * (win32_argc + 1);
228-
if (win32_argv_utf8 == NULL) {
228+
if (!win32_argv_utf8) {
229229
LocalFree(argv_w);
230230
return;
231231
}
@@ -920,15 +920,15 @@ int show_formats(void *optctx, const char *opt, const char *arg)
920920
const char *long_name = NULL;
921921

922922
while ((ofmt = av_oformat_next(ofmt))) {
923-
if ((name == NULL || strcmp(ofmt->name, name) < 0) &&
923+
if ((!name || strcmp(ofmt->name, name) < 0) &&
924924
strcmp(ofmt->name, last_name) > 0) {
925925
name = ofmt->name;
926926
long_name = ofmt->long_name;
927927
encode = 1;
928928
}
929929
}
930930
while ((ifmt = av_iformat_next(ifmt))) {
931-
if ((name == NULL || strcmp(ifmt->name, name) < 0) &&
931+
if ((!name || strcmp(ifmt->name, name) < 0) &&
932932
strcmp(ifmt->name, last_name) > 0) {
933933
name = ifmt->name;
934934
long_name = ifmt->long_name;
@@ -937,7 +937,7 @@ int show_formats(void *optctx, const char *opt, const char *arg)
937937
if (name && strcmp(ifmt->name, name) == 0)
938938
decode = 1;
939939
}
940-
if (name == NULL)
940+
if (!name)
941941
break;
942942
last_name = name;
943943

compat/getopt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static int getopt(int argc, char *argv[], char *opts)
5353
return EOF;
5454
}
5555
optopt = c = argv[optind][sp];
56-
if (c == ':' || (cp = strchr(opts, c)) == NULL) {
56+
if (c == ':' || !(cp = strchr(opts, c))) {
5757
fprintf(stderr, ": illegal option -- %c\n", c);
5858
if (argv[optind][++sp] == '\0') {
5959
optind++;

libavcodec/atrac3.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,7 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx)
882882

883883
q->decoded_bytes_buffer = av_mallocz(FFALIGN(avctx->block_align, 4) +
884884
FF_INPUT_BUFFER_PADDING_SIZE);
885-
if (q->decoded_bytes_buffer == NULL)
885+
if (!q->decoded_bytes_buffer)
886886
return AVERROR(ENOMEM);
887887

888888
avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;

libavcodec/cook.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1218,7 +1218,7 @@ static av_cold int cook_decode_init(AVCodecContext *avctx)
12181218
av_mallocz(avctx->block_align
12191219
+ DECODE_BYTES_PAD1(avctx->block_align)
12201220
+ FF_INPUT_BUFFER_PADDING_SIZE);
1221-
if (q->decoded_bytes_buffer == NULL)
1221+
if (!q->decoded_bytes_buffer)
12221222
return AVERROR(ENOMEM);
12231223

12241224
/* Initialize transform. */

libavcodec/dvbsub.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ static int encode_dvb_subtitles(DVBSubtitleContext *s,
205205

206206
page_id = 1;
207207

208-
if (h->num_rects == 0 || h->rects == NULL)
208+
if (h->num_rects == 0 || !h->rects)
209209
return -1;
210210

211211
*q++ = 0x00; /* subtitle_stream_id */

libavcodec/dvdsubdec.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ static int decode_dvd_subtitles(DVDSubContext *ctx, AVSubtitle *sub_header,
360360
if (sub_header->num_rects > 0)
361361
return is_menu;
362362
fail:
363-
if (sub_header->rects != NULL) {
363+
if (!sub_header->rects) {
364364
for (i = 0; i < sub_header->num_rects; i++) {
365365
av_freep(&sub_header->rects[i]->pict.data[0]);
366366
av_freep(&sub_header->rects[i]->pict.data[1]);
@@ -391,7 +391,7 @@ static int find_smallest_bounding_rectangle(AVSubtitle *s)
391391
int y1, y2, x1, x2, y, w, h, i;
392392
uint8_t *bitmap;
393393

394-
if (s->num_rects == 0 || s->rects == NULL || s->rects[0]->w <= 0 || s->rects[0]->h <= 0)
394+
if (s->num_rects == 0 || !s->rects || s->rects[0]->w <= 0 || s->rects[0]->h <= 0)
395395
return 0;
396396

397397
for(i = 0; i < s->rects[0]->nb_colors; i++) {

libavcodec/dvdsubenc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ static int encode_dvd_subtitles(uint8_t *outbuf, int outbuf_size,
9797
unsigned long hist[256];
9898
int cmap[256];
9999

100-
if (rects == 0 || h->rects == NULL)
100+
if (rects == 0 || !h->rects)
101101
return -1;
102102
if (rects > 20)
103103
rects = 20;

0 commit comments

Comments
 (0)