Browse code

Merge commit '4b1f5e5090abed6c618c8ba380cd7d28d140f867'

* commit '4b1f5e5090abed6c618c8ba380cd7d28d140f867':
cosmetics: Write NULL pointer inequality checks more compactly

Conflicts:
libavcodec/dvdsubdec.c
libavcodec/h263dec.c
libavcodec/libxvid.c
libavcodec/rv10.c
libavcodec/utils.c
libavformat/format.c
libavformat/matroskadec.c
libavformat/segment.c
libavutil/opt.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>

Michael Niedermayer authored on 2014/08/16 04:21:14
Showing 21 changed files
... ...
@@ -205,7 +205,7 @@ static const OptionDef *find_option(const OptionDef *po, const char *name)
205 205
     const char *p = strchr(name, ':');
206 206
     int len = p ? p - name : strlen(name);
207 207
 
208
-    while (po->name != NULL) {
208
+    while (po->name) {
209 209
         if (!strncmp(name, po->name, len) && strlen(po->name) == len)
210 210
             break;
211 211
         po++;
... ...
@@ -658,7 +658,7 @@ frame_end:
658 658
             return ret;
659 659
         ff_print_debug_info(s, s->current_picture_ptr, pict);
660 660
         ff_mpv_export_qp_table(s, pict, s->current_picture_ptr, FF_QSCALE_TYPE_MPEG1);
661
-    } else if (s->last_picture_ptr != NULL) {
661
+    } else if (s->last_picture_ptr) {
662 662
         if ((ret = av_frame_ref(pict, s->last_picture_ptr->f)) < 0)
663 663
             return ret;
664 664
         ff_print_debug_info(s, s->last_picture_ptr, pict);
... ...
@@ -811,7 +811,7 @@ int ff_h264_decode_ref_pic_marking(H264Context *h, GetBitContext *gb,
811 811
                             (h->max_pic_num - 1);
812 812
 #if 0
813 813
                     if (mmco[i].short_pic_num >= h->short_ref_count ||
814
-                        !h->short_ref[ mmco[i].short_pic_num ]) {
814
+                        !h->short_ref[mmco[i].short_pic_num]) {
815 815
                         av_log(s->avctx, AV_LOG_ERROR,
816 816
                                "illegal short ref in memory management control "
817 817
                                "operation %d\n", mmco);
... ...
@@ -196,7 +196,7 @@ static void coded_frame_add(void *list, struct FrameListData *cx_frame)
196 196
 {
197 197
     struct FrameListData **p = list;
198 198
 
199
-    while (*p != NULL)
199
+    while (*p)
200 200
         p = &(*p)->next;
201 201
     *p = cx_frame;
202 202
     cx_frame->next = NULL;
... ...
@@ -139,7 +139,7 @@ static int xvid_ff_2pass_destroy(struct xvid_context *ref,
139 139
                                 xvid_plg_destroy_t *param) {
140 140
     /* Currently cannot think of anything to do on destruction */
141 141
     /* Still, the framework should be here for reference/use */
142
-    if( ref->twopassbuffer != NULL )
142
+    if (ref->twopassbuffer)
143 143
         ref->twopassbuffer[0] = 0;
144 144
     return 0;
145 145
 }
... ...
@@ -789,7 +789,7 @@ static av_cold int xvid_encode_close(AVCodecContext *avctx) {
789 789
     x->encoder_handle = NULL;
790 790
 
791 791
     av_freep(&avctx->extradata);
792
-    if( x->twopassbuffer != NULL ) {
792
+    if (x->twopassbuffer) {
793 793
         av_freep(&x->twopassbuffer);
794 794
         av_freep(&x->old_twopassbuffer);
795 795
         avctx->stats_out = NULL;
... ...
@@ -2067,7 +2067,7 @@ static int slice_end(AVCodecContext *avctx, AVFrame *pict)
2067 2067
                 s->picture_number++;
2068 2068
             /* latency of 1 frame for I- and P-frames */
2069 2069
             /* XXX: use another variable than picture_number */
2070
-            if (s->last_picture_ptr != NULL) {
2070
+            if (s->last_picture_ptr) {
2071 2071
                 int ret = av_frame_ref(pict, s->last_picture_ptr->f);
2072 2072
                 if (ret < 0)
2073 2073
                     return ret;
... ...
@@ -462,7 +462,7 @@ static void qdm2_decode_sub_packet_header(GetBitContext *gb,
462 462
 static QDM2SubPNode *qdm2_search_subpacket_type_in_list(QDM2SubPNode *list,
463 463
                                                         int type)
464 464
 {
465
-    while (list != NULL && list->packet != NULL) {
465
+    while (list && list->packet) {
466 466
         if (list->packet->type == type)
467 467
             return list;
468 468
         list = list->next;
... ...
@@ -1248,23 +1248,23 @@ static void process_synthesis_subpackets(QDM2Context *q, QDM2SubPNode *list)
1248 1248
     QDM2SubPNode *nodes[4];
1249 1249
 
1250 1250
     nodes[0] = qdm2_search_subpacket_type_in_list(list, 9);
1251
-    if (nodes[0] != NULL)
1251
+    if (nodes[0])
1252 1252
         process_subpacket_9(q, nodes[0]);
1253 1253
 
1254 1254
     nodes[1] = qdm2_search_subpacket_type_in_list(list, 10);
1255
-    if (nodes[1] != NULL)
1255
+    if (nodes[1])
1256 1256
         process_subpacket_10(q, nodes[1]);
1257 1257
     else
1258 1258
         process_subpacket_10(q, NULL);
1259 1259
 
1260 1260
     nodes[2] = qdm2_search_subpacket_type_in_list(list, 11);
1261
-    if (nodes[0] != NULL && nodes[1] != NULL && nodes[2] != NULL)
1261
+    if (nodes[0] && nodes[1] && nodes[2])
1262 1262
         process_subpacket_11(q, nodes[2]);
1263 1263
     else
1264 1264
         process_subpacket_11(q, NULL);
1265 1265
 
1266 1266
     nodes[3] = qdm2_search_subpacket_type_in_list(list, 12);
1267
-    if (nodes[0] != NULL && nodes[1] != NULL && nodes[3] != NULL)
1267
+    if (nodes[0] && nodes[1] && nodes[3])
1268 1268
         process_subpacket_12(q, nodes[3]);
1269 1269
     else
1270 1270
         process_subpacket_12(q, NULL);
... ...
@@ -1389,7 +1389,7 @@ static void qdm2_decode_super_block(QDM2Context *q)
1389 1389
         }
1390 1390
     } // Packet bytes loop
1391 1391
 
1392
-    if (q->sub_packet_list_D[0].packet != NULL) {
1392
+    if (q->sub_packet_list_D[0].packet) {
1393 1393
         process_synthesis_subpackets(q, q->sub_packet_list_D);
1394 1394
         q->do_synth_filter = 1;
1395 1395
     } else if (q->do_synth_filter) {
... ...
@@ -1987,7 +1987,7 @@ static int qdm2_decode(QDM2Context *q, const uint8_t *in, int16_t *out)
1987 1987
     for (ch = 0; ch < q->channels; ch++) {
1988 1988
         qdm2_calculate_fft(q, ch, q->sub_packet);
1989 1989
 
1990
-        if (!q->has_errors && q->sub_packet_list_C[0].packet != NULL) {
1990
+        if (!q->has_errors && q->sub_packet_list_C[0].packet) {
1991 1991
             SAMPLES_NEEDED_2("has errors, and C list is not empty")
1992 1992
             return -1;
1993 1993
         }
... ...
@@ -760,7 +760,7 @@ static int rv10_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
760 760
             i++;
761 761
     }
762 762
 
763
-    if (s->current_picture_ptr != NULL && s->mb_y >= s->mb_height) {
763
+    if (s->current_picture_ptr && s->mb_y >= s->mb_height) {
764 764
         ff_er_frame_end(&s->er);
765 765
         ff_mpv_frame_end(s);
766 766
 
... ...
@@ -769,7 +769,7 @@ static int rv10_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
769 769
                 return ret;
770 770
             ff_print_debug_info(s, s->current_picture_ptr, pict);
771 771
             ff_mpv_export_qp_table(s, pict, s->current_picture_ptr, FF_QSCALE_TYPE_MPEG1);
772
-        } else if (s->last_picture_ptr != NULL) {
772
+        } else if (s->last_picture_ptr) {
773 773
             if ((ret = av_frame_ref(pict, s->last_picture_ptr->f)) < 0)
774 774
                 return ret;
775 775
             ff_print_debug_info(s, s->last_picture_ptr, pict);
... ...
@@ -1606,7 +1606,7 @@ static int finish_frame(AVCodecContext *avctx, AVFrame *pict)
1606 1606
         ff_print_debug_info(s, s->current_picture_ptr, pict);
1607 1607
         ff_mpv_export_qp_table(s, pict, s->current_picture_ptr, FF_QSCALE_TYPE_MPEG1);
1608 1608
         got_picture = 1;
1609
-    } else if (s->last_picture_ptr != NULL) {
1609
+    } else if (s->last_picture_ptr) {
1610 1610
         if ((ret = av_frame_ref(pict, s->last_picture_ptr->f)) < 0)
1611 1611
             return ret;
1612 1612
         ff_print_debug_info(s, s->last_picture_ptr, pict);
... ...
@@ -643,7 +643,7 @@ static int video_get_buffer(AVCodecContext *s, AVFrame *pic)
643 643
     FramePool *pool = s->internal->pool;
644 644
     int i;
645 645
 
646
-    if (pic->data[0] != NULL) {
646
+    if (pic->data[0]) {
647 647
         av_log(s, AV_LOG_ERROR, "pic->data[0]!=NULL in avcodec_default_get_buffer\n");
648 648
         return -1;
649 649
     }
... ...
@@ -6229,7 +6229,7 @@ image:
6229 6229
                 goto err;
6230 6230
             ff_print_debug_info(s, s->current_picture_ptr, pict);
6231 6231
             *got_frame = 1;
6232
-        } else if (s->last_picture_ptr != NULL) {
6232
+        } else if (s->last_picture_ptr) {
6233 6233
             if ((ret = av_frame_ref(pict, s->last_picture_ptr->f)) < 0)
6234 6234
                 goto err;
6235 6235
             ff_print_debug_info(s, s->last_picture_ptr, pict);
... ...
@@ -98,7 +98,7 @@ int ffurl_register_protocol(URLProtocol *protocol)
98 98
 {
99 99
     URLProtocol **p;
100 100
     p = &first_protocol;
101
-    while (*p != NULL)
101
+    while (*p)
102 102
         p = &(*p)->next;
103 103
     *p             = protocol;
104 104
     protocol->next = NULL;
... ...
@@ -157,7 +157,7 @@ static int http_open_cnx_internal(URLContext *h, AVDictionary **options)
157 157
 
158 158
     proxy_path = getenv("http_proxy");
159 159
     use_proxy  = !ff_http_match_no_proxy(getenv("no_proxy"), hostname) &&
160
-                 proxy_path != NULL && av_strstart(proxy_path, "http://", NULL);
160
+                 proxy_path && av_strstart(proxy_path, "http://", NULL);
161 161
 
162 162
     if (!strcmp(proto, "https")) {
163 163
         lower_proto = "tls";
... ...
@@ -1748,7 +1748,7 @@ static int matroska_parse_tracks(AVFormatContext *s)
1748 1748
 
1749 1749
         if (!strcmp(track->codec_id, "V_MS/VFW/FOURCC") &&
1750 1750
              track->codec_priv.size >= 40               &&
1751
-            track->codec_priv.data != NULL) {
1751
+            track->codec_priv.data) {
1752 1752
             track->ms_compat    = 1;
1753 1753
             bit_depth           = AV_RL16(track->codec_priv.data + 14);
1754 1754
             fourcc              = AV_RL32(track->codec_priv.data + 16);
... ...
@@ -1760,7 +1760,7 @@ static int matroska_parse_tracks(AVFormatContext *s)
1760 1760
             extradata_offset    = 40;
1761 1761
         } else if (!strcmp(track->codec_id, "A_MS/ACM") &&
1762 1762
                    track->codec_priv.size >= 14         &&
1763
-                   track->codec_priv.data != NULL) {
1763
+                   track->codec_priv.data) {
1764 1764
             int ret;
1765 1765
             ffio_init_context(&b, track->codec_priv.data,
1766 1766
                               track->codec_priv.size,
... ...
@@ -1781,7 +1781,7 @@ static int matroska_parse_tracks(AVFormatContext *s)
1781 1781
             }
1782 1782
         } else if (!strcmp(track->codec_id, "V_QUICKTIME") &&
1783 1783
                    (track->codec_priv.size >= 21)          &&
1784
-                   (track->codec_priv.data != NULL)) {
1784
+                   (track->codec_priv.data)) {
1785 1785
             fourcc   = AV_RL32(track->codec_priv.data + 4);
1786 1786
             codec_id = ff_codec_get_id(ff_codec_movvideo_tags, fourcc);
1787 1787
             if (ff_codec_get_id(ff_codec_movvideo_tags, AV_RL32(track->codec_priv.data))) {
... ...
@@ -4008,7 +4008,7 @@ static int mov_write_header(AVFormatContext *s)
4008 4008
     /* Default mode == MP4 */
4009 4009
     mov->mode = MODE_MP4;
4010 4010
 
4011
-    if (s->oformat != NULL) {
4011
+    if (s->oformat) {
4012 4012
         if (!strcmp("3gp", s->oformat->name)) mov->mode = MODE_3GP;
4013 4013
         else if (!strcmp("3g2", s->oformat->name)) mov->mode = MODE_3GP|MODE_3G2;
4014 4014
         else if (!strcmp("mov", s->oformat->name)) mov->mode = MODE_MOV;
... ...
@@ -372,7 +372,7 @@ static int gen_connect(URLContext *s, RTMPContext *rt)
372 372
         char *param = rt->conn;
373 373
 
374 374
         // Write arbitrary AMF data to the Connect message.
375
-        while (param != NULL) {
375
+        while (param) {
376 376
             char *sep;
377 377
             param += strspn(param, " ");
378 378
             if (!*param)
... ...
@@ -193,7 +193,7 @@ static int tls_open(URLContext *h, const char *uri, int flags)
193 193
 
194 194
     proxy_path = getenv("http_proxy");
195 195
     use_proxy = !ff_http_match_no_proxy(getenv("no_proxy"), host) &&
196
-                proxy_path != NULL && av_strstart(proxy_path, "http://", NULL);
196
+                proxy_path && av_strstart(proxy_path, "http://", NULL);
197 197
 
198 198
     if (use_proxy) {
199 199
         char proxy_host[200], proxy_auth[200], dest[200];
... ...
@@ -111,7 +111,7 @@ void ff_make_absolute_url(char *buf, int size, const char *base,
111 111
 
112 112
     /* Strip off any query string from base */
113 113
     path_query = strchr(buf, '?');
114
-    if (path_query != NULL)
114
+    if (path_query)
115 115
         *path_query = '\0';
116 116
 
117 117
     /* Is relative path just a new query part? */
... ...
@@ -1183,7 +1183,7 @@ void av_opt_set_defaults2(void *s, int mask, int flags)
1183 1183
 {
1184 1184
 #endif
1185 1185
     const AVOption *opt = NULL;
1186
-    while ((opt = av_opt_next(s, opt)) != NULL) {
1186
+    while ((opt = av_opt_next(s, opt))) {
1187 1187
         void *dst = ((uint8_t*)s) + opt->offset;
1188 1188
 #if FF_API_OLD_AVOPTIONS
1189 1189
         if ((opt->flags & mask) != flags)
... ...
@@ -177,7 +177,7 @@ int main(int argc, char **argv)
177 177
         return 1;
178 178
     }
179 179
 
180
-    if ((ext = strrchr(argv[1], '.')) != NULL && !strcmp(ext, ".wav"))
180
+    if ((ext = strrchr(argv[1], '.')) && !strcmp(ext, ".wav"))
181 181
         put_wav_header(sample_rate, nb_channels, 6 * sample_rate);
182 182
 
183 183
     /* 1 second of single freq sine at 1000 Hz */
... ...
@@ -329,7 +329,7 @@ static int handle_file(struct Tracks *tracks, const char *file, int split,
329 329
         tracks->tracks[tracks->nb_tracks] = track;
330 330
 
331 331
         track->name = file;
332
-        if ((ptr = strrchr(file, '/')) != NULL)
332
+        if ((ptr = strrchr(file, '/')))
333 333
             track->name = ptr + 1;
334 334
 
335 335
         track->bitrate   = st->codec->bit_rate;