From 81a663f49edd265dc846ff3854579415cac1d5bb Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Fri, 15 Aug 2014 21:31:59 +0200 Subject: [PATCH] Drop remaining unneeded != NULL MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: Clément Bœsch Signed-off-by: Michael Niedermayer --- cmdutils.c | 2 +- ffmpeg.c | 2 +- ffplay.c | 2 +- ffserver.c | 42 +++++++++++++++--------------- libavcodec/libx264.c | 2 +- libavcodec/mpegaudiodec_template.c | 2 +- libavcodec/parser.c | 2 +- libavfilter/af_amix.c | 4 +-- libavfilter/libmpcodecs/vf_eq2.c | 6 ++--- libavformat/lrcenc.c | 6 ++--- libavformat/matroskadec.c | 2 +- libavformat/mov.c | 2 +- libavformat/rtpdec_h264.c | 2 +- libavformat/sctp.c | 2 +- libavformat/webmdashenc.c | 2 +- libpostproc/postprocess.c | 12 ++++----- 16 files changed, 46 insertions(+), 46 deletions(-) diff --git a/cmdutils.c b/cmdutils.c index 53444984ddc..a71c7db8cf8 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -166,7 +166,7 @@ void show_help_options(const OptionDef *options, const char *msg, int req_flags, int first; first = 1; - for (po = options; po->name != NULL; po++) { + for (po = options; po->name; po++) { char buf[64]; if (((po->flags & req_flags) != req_flags) || diff --git a/ffmpeg.c b/ffmpeg.c index 2582fbf5013..fa907b4c45d 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -2071,7 +2071,7 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt) if (!ist->saw_first_ts) { ist->dts = ist->st->avg_frame_rate.num ? - ist->dec_ctx->has_b_frames * AV_TIME_BASE / av_q2d(ist->st->avg_frame_rate) : 0; ist->pts = 0; - if (pkt != NULL && pkt->pts != AV_NOPTS_VALUE && !ist->decoding_needed) { + if (pkt && pkt->pts != AV_NOPTS_VALUE && !ist->decoding_needed) { ist->dts += av_rescale_q(pkt->pts, ist->st->time_base, AV_TIME_BASE_Q); ist->pts = ist->dts; //unused but better to set it to a value thats not totally wrong } diff --git a/ffplay.c b/ffplay.c index 6a1660765cb..1af4764746e 100644 --- a/ffplay.c +++ b/ffplay.c @@ -441,7 +441,7 @@ static void packet_queue_flush(PacketQueue *q) MyAVPacketList *pkt, *pkt1; SDL_LockMutex(q->mutex); - for (pkt = q->first_pkt; pkt != NULL; pkt = pkt1) { + for (pkt = q->first_pkt; pkt; pkt = pkt1) { pkt1 = pkt->next; av_free_packet(&pkt->pkt); av_freep(&pkt); diff --git a/ffserver.c b/ffserver.c index e2e0f68757b..8acc0401ae6 100644 --- a/ffserver.c +++ b/ffserver.c @@ -592,7 +592,7 @@ static void start_multicast(void) int default_port, stream_index; default_port = 6000; - for(stream = first_stream; stream != NULL; stream = stream->next) { + for(stream = first_stream; stream; stream = stream->next) { if (stream->is_multicast) { unsigned random0 = av_lfg_get(&random_state); unsigned random1 = av_lfg_get(&random_state); @@ -696,7 +696,7 @@ static int http_server(void) /* wait for events on each HTTP handle */ c = first_http_ctx; delay = 1000; - while (c != NULL) { + while (c) { int fd; fd = c->fd; switch(c->state) { @@ -763,7 +763,7 @@ static int http_server(void) } /* now handle the events */ - for(c = first_http_ctx; c != NULL; c = c_next) { + for(c = first_http_ctx; c; c = c_next) { c_next = c->next; if (handle_connection(c) < 0) { log_connection(c); @@ -881,7 +881,7 @@ static void close_connection(HTTPContext *c) /* remove connection from list */ cp = &first_http_ctx; - while ((*cp) != NULL) { + while (*cp) { c1 = *cp; if (c1 == c) *cp = c->next; @@ -890,7 +890,7 @@ static void close_connection(HTTPContext *c) } /* remove references, if any (XXX: do it faster) */ - for(c1 = first_http_ctx; c1 != NULL; c1 = c1->next) { + for(c1 = first_http_ctx; c1; c1 = c1->next) { if (c1->rtsp_c == c) c1->rtsp_c = NULL; } @@ -1486,7 +1486,7 @@ static void compute_real_filename(char *filename, int max_size) p = strrchr(file1, '.'); if (p) *p = '\0'; - for(stream = first_stream; stream != NULL; stream = stream->next) { + for(stream = first_stream; stream; stream = stream->next) { av_strlcpy(file2, stream->filename, sizeof(file2)); p = strrchr(file2, '.'); if (p) @@ -1595,7 +1595,7 @@ static int http_parse_request(HTTPContext *c) av_strlcpy(filename, "index.html", sizeof(filename) - 1); stream = first_stream; - while (stream != NULL) { + while (stream) { if (!strcmp(stream->filename, filename) && validate_acl(stream, c)) break; stream = stream->next; @@ -1974,7 +1974,7 @@ static void compute_status(HTTPContext *c) avio_printf(pb, "\n"); avio_printf(pb, "
PathServed
Conns

bytes
FormatBit rate
kbits/s
Video
kbits/s

Codec
Audio
kbits/s

Codec
Feed\n"); stream = first_stream; - while (stream != NULL) { + while (stream) { char sfilename[1024]; char *eosf; @@ -2063,7 +2063,7 @@ static void compute_status(HTTPContext *c) avio_printf(pb, "
\n"); stream = first_stream; - while (stream != NULL) { + while (stream) { if (stream->feed == stream) { avio_printf(pb, "

Feed %s

", stream->filename); if (stream->pid) { @@ -2141,7 +2141,7 @@ static void compute_status(HTTPContext *c) avio_printf(pb, "#FileIPProtoStateTarget bits/secActual bits/secBytes transferred\n"); c1 = first_http_ctx; i = 0; - while (c1 != NULL) { + while (c1) { int bitrate; int j; @@ -2785,7 +2785,7 @@ static int http_receive_data(HTTPContext *c) } /* wake up any waiting connections */ - for(c1 = first_http_ctx; c1 != NULL; c1 = c1->next) { + for(c1 = first_http_ctx; c1; c1 = c1->next) { if (c1->state == HTTPSTATE_WAIT_FEED && c1->stream->feed == c->stream->feed) c1->state = HTTPSTATE_SEND_DATA; @@ -2841,7 +2841,7 @@ static int http_receive_data(HTTPContext *c) c->stream->feed_opened = 0; close(c->feed_fd); /* wake up any waiting connections to stop waiting for feed */ - for(c1 = first_http_ctx; c1 != NULL; c1 = c1->next) { + for(c1 = first_http_ctx; c1; c1 = c1->next) { if (c1->state == HTTPSTATE_WAIT_FEED && c1->stream->feed == c->stream->feed) c1->state = HTTPSTATE_SEND_DATA_TRAILER; @@ -3043,7 +3043,7 @@ static void rtsp_cmd_describe(HTTPContext *c, const char *url) if (*path == '/') path++; - for(stream = first_stream; stream != NULL; stream = stream->next) { + for(stream = first_stream; stream; stream = stream->next) { if (!stream->is_feed && stream->fmt && !strcmp(stream->fmt->name, "rtp") && !strcmp(path, stream->filename)) { @@ -3081,7 +3081,7 @@ static HTTPContext *find_rtp_session(const char *session_id) if (session_id[0] == '\0') return NULL; - for(c = first_http_ctx; c != NULL; c = c->next) { + for(c = first_http_ctx; c; c = c->next) { if (!strcmp(c->session_id, session_id)) return c; } @@ -3121,7 +3121,7 @@ static void rtsp_cmd_setup(HTTPContext *c, const char *url, path++; /* now check each stream */ - for(stream = first_stream; stream != NULL; stream = stream->next) { + for(stream = first_stream; stream; stream = stream->next) { if (!stream->is_feed && stream->fmt && !strcmp(stream->fmt->name, "rtp")) { /* accept aggregate filenames only if single stream */ @@ -3582,7 +3582,7 @@ static void remove_stream(FFStream *stream) { FFStream **ps; ps = &first_stream; - while (*ps != NULL) { + while (*ps) { if (*ps == stream) *ps = (*ps)->next; else @@ -3648,7 +3648,7 @@ static void build_file_streams(void) int i, ret; /* gather all streams */ - for(stream = first_stream; stream != NULL; stream = stream_next) { + for(stream = first_stream; stream; stream = stream_next) { AVFormatContext *infile = NULL; stream_next = stream->next; if (stream->stream_type == STREAM_TYPE_LIVE && @@ -3700,7 +3700,7 @@ static void build_feed_streams(void) int i; /* gather all streams */ - for(stream = first_stream; stream != NULL; stream = stream->next) { + for(stream = first_stream; stream; stream = stream->next) { feed = stream->feed; if (feed) { if (stream->is_feed) { @@ -3715,7 +3715,7 @@ static void build_feed_streams(void) } /* create feed files if needed */ - for(feed = first_feed; feed != NULL; feed = feed->next_feed) { + for(feed = first_feed; feed; feed = feed->next_feed) { int fd; if (avio_check(feed->feed_filename, AVIO_FLAG_READ) > 0) { @@ -3847,7 +3847,7 @@ static void compute_bandwidth(void) int i; FFStream *stream; - for(stream = first_stream; stream != NULL; stream = stream->next) { + for(stream = first_stream; stream; stream = stream->next) { bandwidth = 0; for(i=0;inb_streams;i++) { AVStream *st = stream->streams[i]; @@ -4294,7 +4294,7 @@ static int parse_ffconfig(const char *filename) FFStream *sfeed; sfeed = first_feed; - while (sfeed != NULL) { + while (sfeed) { if (!strcmp(sfeed->filename, arg)) break; sfeed = sfeed->next_feed; diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index ab3d59a272a..779358142f0 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -314,7 +314,7 @@ static av_cold int X264_close(AVCodecContext *avctx) #define OPT_STR(opt, param) \ do { \ int ret; \ - if (param!=NULL && (ret = x264_param_parse(&x4->params, opt, param)) < 0) { \ + if (param && (ret = x264_param_parse(&x4->params, opt, param)) < 0) { \ if(ret == X264_PARAM_BAD_NAME) \ av_log(avctx, AV_LOG_ERROR, \ "bad option '%s': '%s'\n", opt, param); \ diff --git a/libavcodec/mpegaudiodec_template.c b/libavcodec/mpegaudiodec_template.c index e2523b49cab..c4c03d91063 100644 --- a/libavcodec/mpegaudiodec_template.c +++ b/libavcodec/mpegaudiodec_template.c @@ -1603,7 +1603,7 @@ static int mp_decode_frame(MPADecodeContext *s, OUT_INT **samples, /* get output buffer */ if (!samples) { - av_assert0(s->frame != NULL); + av_assert0(s->frame); s->frame->nb_samples = s->avctx->frame_size; if ((ret = ff_get_buffer(s->avctx, s->frame, 0)) < 0) return ret; diff --git a/libavcodec/parser.c b/libavcodec/parser.c index 71449ca3aba..55c2f527a20 100644 --- a/libavcodec/parser.c +++ b/libavcodec/parser.c @@ -54,7 +54,7 @@ AVCodecParserContext *av_parser_init(int codec_id) if (codec_id == AV_CODEC_ID_NONE) return NULL; - for (parser = av_first_parser; parser != NULL; parser = parser->next) { + for (parser = av_first_parser; parser; parser = parser->next) { if (parser->codec_ids[0] == codec_id || parser->codec_ids[1] == codec_id || parser->codec_ids[2] == codec_id || diff --git a/libavfilter/af_amix.c b/libavfilter/af_amix.c index 1eef70d8c4a..d8a6651fceb 100644 --- a/libavfilter/af_amix.c +++ b/libavfilter/af_amix.c @@ -110,7 +110,7 @@ static void frame_list_remove_samples(FrameList *frame_list, int nb_samples) int samples = nb_samples; while (samples > 0) { FrameInfo *info = frame_list->list; - av_assert0(info != NULL); + av_assert0(info); if (info->nb_samples <= samples) { samples -= info->nb_samples; frame_list->list = info->next; @@ -142,7 +142,7 @@ static int frame_list_add_frame(FrameList *frame_list, int nb_samples, int64_t p frame_list->list = info; frame_list->end = info; } else { - av_assert0(frame_list->end != NULL); + av_assert0(frame_list->end); frame_list->end->next = info; frame_list->end = info; } diff --git a/libavfilter/libmpcodecs/vf_eq2.c b/libavfilter/libmpcodecs/vf_eq2.c index c9c3ff69f46..03568139f33 100644 --- a/libavfilter/libmpcodecs/vf_eq2.c +++ b/libavfilter/libmpcodecs/vf_eq2.c @@ -265,7 +265,7 @@ int put_image (vf_instance_t *vf, mp_image_t *src, double pts) dst = ff_vf_get_image (vf->next, src->imgfmt, MP_IMGTYPE_EXPORT, 0, src->w, src->h); for (i = 0; i < ((src->num_planes>1)?3:1); i++) { - if (eq2->param[i].adjust != NULL) { + if (eq2->param[i].adjust) { dst->planes[i] = eq2->buf[i]; dst->stride[i] = eq2->buf_w[i]; @@ -439,7 +439,7 @@ int query_format (vf_instance_t *vf, unsigned fmt) static void uninit (vf_instance_t *vf) { - if (vf->priv != NULL) { + if (vf->priv) { free (vf->priv->buf[0]); free (vf->priv); } @@ -482,7 +482,7 @@ int vf_open(vf_instance_t *vf, char *args) eq2->ggamma = 1.0; eq2->bgamma = 1.0; - if (args != NULL) { + if (args) { par[0] = 1.0; par[1] = 1.0; par[2] = 0.0; diff --git a/libavformat/lrcenc.c b/libavformat/lrcenc.c index c1afc2ccac6..b316ccd6d81 100644 --- a/libavformat/lrcenc.c +++ b/libavformat/lrcenc.c @@ -64,15 +64,15 @@ static int lrc_write_header(AVFormatContext *s) } for(metadata_item = NULL; (metadata_item = av_dict_get(s->metadata, "", metadata_item, - AV_DICT_IGNORE_SUFFIX)) != NULL;) { + AV_DICT_IGNORE_SUFFIX));) { char *delim; if(!metadata_item->value[0]) { continue; } - while((delim = strchr(metadata_item->value, '\n')) != NULL) { + while((delim = strchr(metadata_item->value, '\n'))) { *delim = ' '; } - while((delim = strchr(metadata_item->value, '\r')) != NULL) { + while((delim = strchr(metadata_item->value, '\r'))) { *delim = ' '; } avio_printf(s->pb, "[%s:%s]\n", diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index dd1478cbf4b..09d23f67ed2 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -1772,7 +1772,7 @@ static int matroska_parse_tracks(AVFormatContext *s) extradata_offset = FFMIN(track->codec_priv.size, 18); } else if (!strcmp(track->codec_id, "A_QUICKTIME") && (track->codec_priv.size >= 86) - && (track->codec_priv.data != NULL)) { + && (track->codec_priv.data)) { fourcc = AV_RL32(track->codec_priv.data + 4); codec_id = ff_codec_get_id(ff_codec_movaudio_tags, fourcc); if (ff_codec_get_id(ff_codec_movaudio_tags, AV_RL32(track->codec_priv.data))) { diff --git a/libavformat/mov.c b/libavformat/mov.c index 767833ed056..a531fd47c88 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -3081,7 +3081,7 @@ static int mov_read_uuid(MOVContext *c, AVIOContext *pb, MOVAtom atom) } ptr = buffer; - while ((ptr = av_stristr(ptr, "systemBitrate=\"")) != NULL) { + while ((ptr = av_stristr(ptr, "systemBitrate=\""))) { ptr += sizeof("systemBitrate=\"") - 1; c->bitrates_count++; c->bitrates = av_realloc_f(c->bitrates, c->bitrates_count, sizeof(*c->bitrates)); diff --git a/libavformat/rtpdec_h264.c b/libavformat/rtpdec_h264.c index 51704aaf732..4dbbae770bb 100644 --- a/libavformat/rtpdec_h264.c +++ b/libavformat/rtpdec_h264.c @@ -71,7 +71,7 @@ static int sdp_parse_fmtp_config_h264(AVFormatContext *s, { AVCodecContext *codec = stream->codec; assert(codec->codec_id == AV_CODEC_ID_H264); - assert(h264_data != NULL); + assert(h264_data); if (!strcmp(attr, "packetization-mode")) { av_log(s, AV_LOG_DEBUG, "RTP Packetization Mode: %d\n", atoi(value)); diff --git a/libavformat/sctp.c b/libavformat/sctp.c index f88cd2795d5..a4406d1e402 100644 --- a/libavformat/sctp.c +++ b/libavformat/sctp.c @@ -98,7 +98,7 @@ static int ff_sctp_recvmsg(int s, void *msg, size_t len, struct sockaddr *from, if (msg_flags) *msg_flags = inmsg.msg_flags; - for (cmsg = CMSG_FIRSTHDR(&inmsg); cmsg != NULL; + for (cmsg = CMSG_FIRSTHDR(&inmsg); cmsg; cmsg = CMSG_NXTHDR(&inmsg, cmsg)) { if ((IPPROTO_SCTP == cmsg->cmsg_level) && (SCTP_SNDRCV == cmsg->cmsg_type)) diff --git a/libavformat/webmdashenc.c b/libavformat/webmdashenc.c index 9cc8d1928c4..fc77c247c71 100644 --- a/libavformat/webmdashenc.c +++ b/libavformat/webmdashenc.c @@ -150,7 +150,7 @@ static int write_adaptation_set(AVFormatContext *s, int as_index) avio_printf(s->pb, " codecs=\"%s\"", get_codec_name(codec->codec_id)); lang = av_dict_get(s->streams[as->streams[0]]->metadata, "language", NULL, 0); - if (lang != NULL) avio_printf(s->pb, " lang=\"%s\"", lang->value); + if (lang) avio_printf(s->pb, " lang=\"%s\"", lang->value); if (codec->codec_type == AVMEDIA_TYPE_VIDEO) { avio_printf(s->pb, " width=\"%d\"", codec->width); diff --git a/libpostproc/postprocess.c b/libpostproc/postprocess.c index 3132d5906b7..794cd30f1a0 100644 --- a/libpostproc/postprocess.c +++ b/libpostproc/postprocess.c @@ -748,7 +748,7 @@ pp_mode *pp_get_mode_by_name_and_quality(const char *name, int quality) options[numOfUnknownOptions] = NULL; /* replace stuff from the replace Table */ - for(i=0; replaceTable[2*i]!=NULL; i++){ + for(i=0; replaceTable[2*i]; i++){ if(!strcmp(replaceTable[2*i], filterName)){ int newlen= strlen(replaceTable[2*i + 1]); int plen; @@ -768,7 +768,7 @@ pp_mode *pp_get_mode_by_name_and_quality(const char *name, int quality) } } - for(i=0; filters[i].shortName!=NULL; i++){ + for(i=0; filters[i].shortName; i++){ if( !strcmp(filters[i].longName, filterName) || !strcmp(filters[i].shortName, filterName)){ ppMode->lumMode &= ~filters[i].mask; @@ -787,7 +787,7 @@ pp_mode *pp_get_mode_by_name_and_quality(const char *name, int quality) int o; ppMode->minAllowedY= 16; ppMode->maxAllowedY= 234; - for(o=0; options[o]!=NULL; o++){ + for(o=0; options[o]; o++){ if( !strcmp(options[o],"fullyrange") ||!strcmp(options[o],"f")){ ppMode->minAllowedY= 0; @@ -801,7 +801,7 @@ pp_mode *pp_get_mode_by_name_and_quality(const char *name, int quality) int o; int numOfNoises=0; - for(o=0; options[o]!=NULL; o++){ + for(o=0; options[o]; o++){ char *tail; ppMode->maxTmpNoise[numOfNoises]= strtol(options[o], &tail, 0); @@ -816,7 +816,7 @@ pp_mode *pp_get_mode_by_name_and_quality(const char *name, int quality) || filters[i].mask == V_A_DEBLOCK || filters[i].mask == H_A_DEBLOCK){ int o; - for(o=0; options[o]!=NULL && o<2; o++){ + for(o=0; options[o] && o<2; o++){ char *tail; int val= strtol(options[o], &tail, 0); if(tail==options[o]) break; @@ -830,7 +830,7 @@ pp_mode *pp_get_mode_by_name_and_quality(const char *name, int quality) int o; ppMode->forcedQuant= 15; - for(o=0; options[o]!=NULL && o<1; o++){ + for(o=0; options[o] && o<1; o++){ char *tail; int val= strtol(options[o], &tail, 0); if(tail==options[o]) break; -- 2.39.5