[FFmpeg-devel,v2,1/2] avformat/utils: simplify the code and remove av_strncasecmp

Submitted by lance.lmwang@gmail.com on Dec. 1, 2019, 2 p.m.

Details

Message ID 20191201140042.26305-1-lance.lmwang@gmail.com
State New
Headers show

Commit Message

lance.lmwang@gmail.com Dec. 1, 2019, 2 p.m.
From: Limin Wang <lance.lmwang@gmail.com>

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
 libavformat/utils.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Comments

Hendrik Leppkes Dec. 1, 2019, 4:32 p.m.
On Sun, Dec 1, 2019 at 3:07 PM <lance.lmwang@gmail.com> wrote:
>
> From: Limin Wang <lance.lmwang@gmail.com>
>
> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> ---
>  libavformat/utils.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/libavformat/utils.c b/libavformat/utils.c
> index 8196442..579e6d6 100644
> --- a/libavformat/utils.c
> +++ b/libavformat/utils.c
> @@ -4854,11 +4854,10 @@ int ff_mkdir_p(const char *path)
>          return -1;
>      }
>
> -    if (!av_strncasecmp(temp, "/", 1) || !av_strncasecmp(temp, "\\", 1)) {
> +    if (*temp == '.')
> +        pos++;
> +    if (*temp == '/' || *temp == '\\')
>          pos++;
> -    } else if (!av_strncasecmp(temp, "./", 2) || !av_strncasecmp(temp, ".\\", 2)) {
> -        pos += 2;
> -    }
>

Is the change in logic intentional? It seems problematic to me to
potentially skip any dot, not just dots followed by a (back)slash.
Afterall names can start with dots.

- Hendrik
lance.lmwang@gmail.com Dec. 2, 2019, 1:02 a.m.
On Sun, Dec 01, 2019 at 05:32:04PM +0100, Hendrik Leppkes wrote:
> On Sun, Dec 1, 2019 at 3:07 PM <lance.lmwang@gmail.com> wrote:
> >
> > From: Limin Wang <lance.lmwang@gmail.com>
> >
> > Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> > ---
> >  libavformat/utils.c | 7 +++----
> >  1 file changed, 3 insertions(+), 4 deletions(-)
> >
> > diff --git a/libavformat/utils.c b/libavformat/utils.c
> > index 8196442..579e6d6 100644
> > --- a/libavformat/utils.c
> > +++ b/libavformat/utils.c
> > @@ -4854,11 +4854,10 @@ int ff_mkdir_p(const char *path)
> >          return -1;
> >      }
> >
> > -    if (!av_strncasecmp(temp, "/", 1) || !av_strncasecmp(temp, "\\", 1)) {
> > +    if (*temp == '.')
> > +        pos++;
> > +    if (*temp == '/' || *temp == '\\')
> >          pos++;
> > -    } else if (!av_strncasecmp(temp, "./", 2) || !av_strncasecmp(temp, ".\\", 2)) {
> > -        pos += 2;
> > -    }
> >
> 
> Is the change in logic intentional? It seems problematic to me to
> potentially skip any dot, not just dots followed by a (back)slash.
> Afterall names can start with dots.

Yes, you're right, I'll update the patch.


> 
> - Hendrik
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

Patch hide | download patch | download mbox

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 8196442..579e6d6 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -4854,11 +4854,10 @@  int ff_mkdir_p(const char *path)
         return -1;
     }
 
-    if (!av_strncasecmp(temp, "/", 1) || !av_strncasecmp(temp, "\\", 1)) {
+    if (*temp == '.')
+        pos++;
+    if (*temp == '/' || *temp == '\\')
         pos++;
-    } else if (!av_strncasecmp(temp, "./", 2) || !av_strncasecmp(temp, ".\\", 2)) {
-        pos += 2;
-    }
 
     for ( ; *pos != '\0'; ++pos) {
         if (*pos == '/' || *pos == '\\') {