From patchwork Mon Sep 16 01:03:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 15085 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id C09DF44532A for ; Mon, 16 Sep 2019 04:33:33 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9B1EC687FE4; Mon, 16 Sep 2019 04:33:33 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-io1-f65.google.com (mail-io1-f65.google.com [209.85.166.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8A229680951 for ; Mon, 16 Sep 2019 04:33:27 +0300 (EEST) Received: by mail-io1-f65.google.com with SMTP id n197so75058481iod.9 for ; Sun, 15 Sep 2019 18:33:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=FqplZFtrZKq8B7NOdA7JRh99+SA3ZorEXJQ/ys2OGIU=; b=ZpDThbhoO489HJcs0Skni+5/B2sUdfv+uuE99rDaefRKmg4N7kpZ7o1TNZe9B+NE8o hwft6ONYddXt9hE25/err7PLgy2z4vnxlMoX4kxF9VvoY4Ab224gHh7OVM/tY1CIK0Uj JBNJyoiZ0JPzy7z7rtam9tDKWSKV33/OZGeUxdASSMktCUzYQDbAOAB1nRJw+BeZadwk mUbeVg9NejotHi66FuxNr1LuILJzj+fduZEAjz4ge9Fb26oGuh9VHRNiMkMHibiY99Hr cz6OHvSo7BRTbHqQ+RwOpKjGg6pWwQ9UoeTazM0h7tX3bSNDRW2mY60oKBQGQqawswTf skzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=FqplZFtrZKq8B7NOdA7JRh99+SA3ZorEXJQ/ys2OGIU=; b=t0Fb/uOTwM/SRHaeBqsI8CS53NFmpqRGTuKwILsXkB5bFnbXUs30idkVeuRFWuP8Oe rMjaxr2cbZOYIqDNmh0A/FcfSVfwB8At4Lx09jaS9YMIO52pq0kPpGCUsiLibUIb9RRj LtsBehZHc/Afym6xGttWP/5PW4s9MPr6cTRlMdm50FzyVkgMMWg8qsiKWTrpXqXN5NDV /lp2FPcSpTuUB8jDkSaupvqQPY5xEU8I9ydQnW04v7owyAwCYH+sp/aZoGoH7l+wJ1U1 MKwbPcAEUFJf3JyUwBKt4T68XQsn8nGBLmLZwPBnD+cnZghqYeQYoY4odJ9mrKvKVbiS DAtg== X-Gm-Message-State: APjAAAVXQJ8RS5ZByG5MZ5yrf2e2OylnoqgepranxKxDkyu0uBh60+XN pYCg6AaWlz0CCFuCpcMXapYPNAgK X-Google-Smtp-Source: APXvYqw1Yw71XB5JTEhlkgkd3rSedFS6yEW0ZxiuPWQQyjyFFm1RUqyp+AcAukyiYxOstrH/X53m3g== X-Received: by 2002:a63:6c46:: with SMTP id h67mr55158849pgc.248.1568595828945; Sun, 15 Sep 2019 18:03:48 -0700 (PDT) Received: from vpn2.localdomain ([47.90.123.189]) by smtp.gmail.com with ESMTPSA id a17sm2797218pfi.178.2019.09.15.18.03.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 15 Sep 2019 18:03:48 -0700 (PDT) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Mon, 16 Sep 2019 09:03:36 +0800 Message-Id: <1568595818-7943-2-git-send-email-lance.lmwang@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568595818-7943-1-git-send-email-lance.lmwang@gmail.com> References: <1568595818-7943-1-git-send-email-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH v1 2/4] avformat/hlsenc: remove the unnecessary null pointer check X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Limin Wang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Limin Wang Signed-off-by: Limin Wang --- libavformat/hlsenc.c | 31 ++----------------------------- 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index 1f2bdfbe4d..b5681a85c7 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -1613,16 +1613,13 @@ static int hls_start(AVFormatContext *s, VariantStream *vs) if (c->use_localtime_mkdir) { const char *dir; char *fn_copy = av_strdup(oc->url); - if (!fn_copy) { - return AVERROR(ENOMEM); - } dir = av_dirname(fn_copy); if (ff_mkdir_p(dir) == -1 && errno != EEXIST) { av_log(oc, AV_LOG_ERROR, "Could not create directory %s with use_localtime_mkdir\n", dir); - av_free(fn_copy); + av_freep(&fn_copy); return AVERROR(errno); } - av_free(fn_copy); + av_freep(&fn_copy); } } else { char *filename = NULL; @@ -1784,11 +1781,6 @@ static int validate_name(int nb_vs, const char *fn) } fn_dup = av_strdup(fn); - if (!fn_dup) { - ret = AVERROR(ENOMEM); - goto fail; - } - filename = av_basename(fn); subdir_name = av_dirname(fn_dup); @@ -1818,11 +1810,6 @@ static int format_name(const char *buf, char **s, int index, const char *varname int ret = 0; orig_buf_dup = av_strdup(buf); - if (!orig_buf_dup) { - ret = AVERROR(ENOMEM); - goto fail; - } - if (!av_stristr(buf, "%v")) { *s = orig_buf_dup; return ret; @@ -1846,11 +1833,6 @@ static int format_name(const char *buf, char **s, int index, const char *varname /* if %v is present in the file's directory, create sub-directory */ if (av_stristr(dir, "%v") && proto && !strcmp(proto, "file")) { mod_buf_dup = av_strdup(*s); - if (!mod_buf_dup) { - ret = AVERROR(ENOMEM); - goto fail; - } - dir = av_dirname(mod_buf_dup); if (ff_mkdir_p(dir) == -1 && errno != EEXIST) { ret = AVERROR(errno); @@ -2151,11 +2133,6 @@ static int update_master_pl_info(AVFormatContext *s) int ret = 0; fn1 = av_strdup(s->url); - if (!fn1) { - ret = AVERROR(ENOMEM); - goto fail; - } - dir = av_dirname(fn1); /** @@ -2164,10 +2141,6 @@ static int update_master_pl_info(AVFormatContext *s) */ if (dir && av_stristr(av_basename(dir), "%v")) { fn2 = av_strdup(dir); - if (!fn2) { - ret = AVERROR(ENOMEM); - goto fail; - } dir = av_dirname(fn2); }