[M120 Migration] Fix build warning 51/307451/2
authorManjeet <manjeet.1@partner.samsung.com>
Fri, 8 Mar 2024 10:11:49 +0000 (15:41 +0530)
committerDae-Hyun Ko <dhyuna.ko@samsung.com>
Mon, 11 Mar 2024 05:21:05 +0000 (05:21 +0000)
The following patch fixes a compilation warning [1] that
occurs during tv build.

[1] "warning: comparison of integers of different
signs: 'int' and 'unsigned int'"

The upper limit of unsigned int and int are different, so in
extreme cases where value of a variable falls in between the
upper limit of int and unsigned int, leads to an infinite loop.

Reference: https://review.tizen.org/gerrit/293395

Change-Id: I7921ffb6a949b7f9c522889e35c9cd9d48268b26
Signed-off-by: Manjeet <manjeet.1@partner.samsung.com>
media/filters/source_buffer_range.cc

index fdc106c..b5e8f47 100644 (file)
@@ -200,7 +200,8 @@ void SourceBufferRange::ModifyFirstFrameForMpeghCodec() {
   // This is used to check whether we do not try to add starting sequence to
   // frame that already had it added while demuxing ie. first uploaded frame
   bool is_starting_sequence_already_present = true;
-  for (int i = 0; i < start_sequence.size() && i < old_data_size; i++) {
+  for (unsigned int i = 0; i < start_sequence.size() && i < old_data_size;
+       i++) {
     if (start_sequence[i] != old_data_[i]) {
       is_starting_sequence_already_present = false;
       break;
@@ -217,12 +218,14 @@ void SourceBufferRange::ModifyFirstFrameForMpeghCodec() {
 
   // Starting sequence inserted in front of new data
   // new_data.insert(new_data.begin(),start_sequence.begin(),start_sequence.end());
-  for (int i = 0; i < start_sequence.size(); i++)
+  for (unsigned int i = 0; i < start_sequence.size(); i++) {
     new_data[i] = start_sequence[i];
+  }
 
   // Loop copying old data to new container
-  for (int i = 0; i < old_data_size; i++)
+  for (unsigned int i = 0; i < old_data_size; i++) {
     new_data[i + start_sequence.size()] = old_data_[i];
+  }
 
   // Creating new buffer based on changed data
   auto new_buffer = StreamParserBuffer::CopyFrom(