diff mbox series

[FFmpeg-devel,07/10] avformat/aadec: Use smaller scope for variables

Message ID AM7PR03MB6660DBE7C9B0156A67BCE16E8F6D9@AM7PR03MB6660.eurprd03.prod.outlook.com
State Accepted
Commit 72745beb44b4ddf60b77833b2edddf80e8f79ef2
Headers show
Series [FFmpeg-devel,01/10] avformat/utils: Make ff_data_to_hex() zero-terminate the string
Related show

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 Dec. 6, 2021, 1:12 a.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavformat/aadec.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/aadec.c b/libavformat/aadec.c
index 840a9968c6..b8a5428f1f 100644
--- a/libavformat/aadec.c
+++ b/libavformat/aadec.c
@@ -71,7 +71,7 @@  static int get_second_size(char *codec_name)
 
 static int aa_read_header(AVFormatContext *s)
 {
-    int i, idx, largest_idx = -1;
+    int largest_idx = -1;
     uint32_t toc_size, npairs, header_seed = 0, start;
     char codec_name[64] = {0};
     uint8_t buf[24];
@@ -80,7 +80,6 @@  static int aa_read_header(AVFormatContext *s)
         uint32_t offset;
         uint32_t size;
     } TOC[MAX_TOC_ENTRIES];
-    uint32_t header_key_part[4];
     uint8_t header_key[16] = {0};
     AADemuxContext *c = s->priv_data;
     char file_key[2 * sizeof(c->file_key) + 1];
@@ -96,7 +95,7 @@  static int aa_read_header(AVFormatContext *s)
     avio_skip(pb, 4); // unidentified integer
     if (toc_size > MAX_TOC_ENTRIES || toc_size < 2)
         return AVERROR_INVALIDDATA;
-    for (i = 0; i < toc_size; i++) { // read TOC
+    for (uint32_t i = 0; i < toc_size; i++) { // read TOC
         avio_skip(pb, 4); // TOC entry index
         TOC[i].offset = avio_rb32(pb); // block offset
         TOC[i].size = avio_rb32(pb); // block size
@@ -105,7 +104,7 @@  static int aa_read_header(AVFormatContext *s)
     npairs = avio_rb32(pb); // read dictionary entries
     if (npairs > MAX_DICTIONARY_ENTRIES)
         return AVERROR_INVALIDDATA;
-    for (i = 0; i < npairs; i++) {
+    for (uint32_t i = 0; i < npairs; i++) {
         char key[128], val[128];
         uint32_t nkey, nval;
 
@@ -121,6 +120,7 @@  static int aa_read_header(AVFormatContext *s)
             av_log(s, AV_LOG_DEBUG, "HeaderSeed is <%s>\n", val);
             header_seed = atoi(val);
         } else if (!strcmp(key, "HeaderKey")) { // this looks like "1234567890 1234567890 1234567890 1234567890"
+            uint32_t header_key_part[4];
             av_log(s, AV_LOG_DEBUG, "HeaderKey is <%s>\n", val);
 
             ret = sscanf(val, "%"SCNu32"%"SCNu32"%"SCNu32"%"SCNu32,
@@ -128,9 +128,8 @@  static int aa_read_header(AVFormatContext *s)
             if (ret != 4)
                 return AVERROR_INVALIDDATA;
 
-            for (idx = 0; idx < 4; idx++) {
+            for (int idx = 0; idx < 4; idx++)
                 AV_WB32(&header_key[idx * 4], header_key_part[idx]); // convert each part to BE!
-            }
             ff_data_to_hex(key, header_key, sizeof(header_key), 1);
             av_log(s, AV_LOG_DEBUG, "Processed HeaderKey is %s\n", key);
         } else {
@@ -195,7 +194,7 @@  static int aa_read_header(AVFormatContext *s)
     }
 
     /* determine, and jump to audio start offset */
-    for (i = 1; i < toc_size; i++) { // skip the first entry!
+    for (uint32_t i = 1; i < toc_size; i++) { // skip the first entry!
         current_size = TOC[i].size;
         if (current_size > largest_size) {
             largest_idx = i;