diff mbox series

[FFmpeg-devel,10/17] avformat/mxfdec: Simplify data->hex string conversion

Message ID AM7PR03MB666000AC25E1E851731BCDA88F929@AM7PR03MB6660.eurprd03.prod.outlook.com
State Superseded
Headers show
Series [FFmpeg-devel,01/17] avformat/mxfenc: Auto-insert h264_mp4toannexb BSF if needed | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Andreas Rheinhardt Nov. 9, 2021, 6:01 p.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavformat/mxfdec.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

Comments

Tomas Härdin Nov. 9, 2021, 9:29 p.m. UTC | #1
tis 2021-11-09 klockan 19:01 +0100 skrev Andreas Rheinhardt:
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavformat/mxfdec.c | 13 +++----------
>  1 file changed, 3 insertions(+), 10 deletions(-)
> 
> diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
> index af9d33f796..4191e82474 100644
> --- a/libavformat/mxfdec.c
> +++ b/libavformat/mxfdec.c
> @@ -1984,22 +1984,15 @@ static int mxf_uid_to_str(UID uid, char
> **str)
>  
>  static int mxf_umid_to_str(UID ul, UID uid, char **str)
>  {
> -    int i;
>      char *p;
>      p = *str = av_mallocz(sizeof(UID) * 4 + 2 + 1);
>      if (!p)
>          return AVERROR(ENOMEM);
>      snprintf(p, 2 + 1, "0x");

Could use strncpy() while you're at it.

/Tomas
diff mbox series

Patch

diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index af9d33f796..4191e82474 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -1984,22 +1984,15 @@  static int mxf_uid_to_str(UID uid, char **str)
 
 static int mxf_umid_to_str(UID ul, UID uid, char **str)
 {
-    int i;
     char *p;
     p = *str = av_mallocz(sizeof(UID) * 4 + 2 + 1);
     if (!p)
         return AVERROR(ENOMEM);
     snprintf(p, 2 + 1, "0x");
     p += 2;
-    for (i = 0; i < sizeof(UID); i++) {
-        snprintf(p, 2 + 1, "%.2X", ul[i]);
-        p += 2;
-
-    }
-    for (i = 0; i < sizeof(UID); i++) {
-        snprintf(p, 2 + 1, "%.2X", uid[i]);
-        p += 2;
-    }
+    ff_data_to_hex(p, ul,  sizeof(UID), 0);
+    p += 2 * sizeof(UID);
+    ff_data_to_hex(p, uid, sizeof(UID), 0);
     return 0;
 }