]> git.imager.perl.org - imager.git/commitdiff
add braces to some multi-line if() and for()
authorTony Cook <tony@develop-help.com>
Mon, 31 Dec 2018 11:11:54 +0000 (22:11 +1100)
committerTony Cook <tony@develop-help.com>
Mon, 31 Dec 2018 11:11:54 +0000 (22:11 +1100)
Coverity complained about this code

fills.c

diff --git a/fills.c b/fills.c
index ea5864760feea726ed274982bc580c4cafc51093..52c51c8e2ba5d3316711dbff52ec157dbe412a04 100644 (file)
--- a/fills.c
+++ b/fills.c
@@ -758,14 +758,16 @@ static i_color interp_i_color(i_color before, i_color after, double pos,
   pos -= floor(pos);
   for (ch = 0; ch < channels; ++ch)
     out.channel[ch] = (1-pos) * before.channel[ch] + pos * after.channel[ch];
-  if (channels > 3 && out.channel[3])
-    for (ch = 0; ch < channels; ++ch)
+  if (channels > 3 && out.channel[3]) {
+    for (ch = 0; ch < channels; ++ch) {
       if (ch != 3) {
         int temp = out.channel[ch] * 255 / out.channel[3];
         if (temp > 255)
           temp = 255;
         out.channel[ch] = temp;
       }
+    }
+  }
 
   return out;
 }
@@ -780,14 +782,16 @@ static i_fcolor interp_i_fcolor(i_fcolor before, i_fcolor after, double pos,
   pos -= floor(pos);
   for (ch = 0; ch < channels; ++ch)
     out.channel[ch] = (1-pos) * before.channel[ch] + pos * after.channel[ch];
-  if (out.channel[3])
-    for (ch = 0; ch < channels; ++ch)
+  if (out.channel[3]) {
+    for (ch = 0; ch < channels; ++ch) {
       if (ch != 3) {
         int temp = out.channel[ch] / out.channel[3];
         if (temp > 1.0)
           temp = 1.0;
         out.channel[ch] = temp;
       }
+    }
+  }
 
   return out;
 }