]> Kevux Git Server - fll/commitdiff
Cleanup: Relocate local variables into block.
authorKevin Day <Kevin@kevux.org>
Fri, 1 Aug 2025 00:47:00 +0000 (19:47 -0500)
committerKevin Day <Kevin@kevux.org>
Fri, 1 Aug 2025 00:47:00 +0000 (19:47 -0500)
The variable should be in a block so that they only exist as long as they need to.

level_2/fll_program/c/program.c

index cdad9cf469370c18c2b0b43afc1dc13ed8cbb857..5bef012240c6daead87be6736ab5a7b3456a31c1 100644 (file)
@@ -432,91 +432,95 @@ extern "C" {
     // 0x10 = output descriptor, 0x20 = error descriptor, 0x40 = input descriptor.
     flag = 0;
 
-    f_file_t file = f_file_t_initialize;
+    {
+      f_file_t file = f_file_t_initialize;
 
-    if (F_type_output_d) {
-      file.stream = F_type_output_d;
-      flag |= 0x1;
+      if (F_type_output_d) {
+        file.stream = F_type_output_d;
+        flag |= 0x1;
 
-      f_file_stream_flush(file);
-    }
-    else {
-      if (F_type_descriptor_output_d != -1) {
-        file.id = F_type_descriptor_output_d;
-        flag |= 0x20;
+        f_file_stream_flush(file);
+      }
+      else {
+        if (F_type_descriptor_output_d != -1) {
+          file.id = F_type_descriptor_output_d;
+          flag |= 0x20;
 
-        f_file_flush(file);
+          f_file_flush(file);
+        }
       }
-    }
 
-    if (F_type_error_d) {
-      file.stream = F_type_error_d;
-      flag |= 0x2;
+      if (F_type_error_d) {
+        file.stream = F_type_error_d;
+        flag |= 0x2;
 
-      f_file_stream_flush(file);
-    }
-    else {
-      if (F_type_descriptor_error_d != -1) {
-        file.id = F_type_descriptor_output_d;
-        flag |= 0x40;
+        f_file_stream_flush(file);
+      }
+      else {
+        if (F_type_descriptor_error_d != -1) {
+          file.id = F_type_descriptor_output_d;
+          flag |= 0x40;
 
-        f_file_flush(file);
+          f_file_flush(file);
+        }
       }
-    }
 
-    if (F_type_input_d) {
-      file.stream = F_type_input_d;
-      flag |= 0x4;
+      if (F_type_input_d) {
+        file.stream = F_type_input_d;
+        flag |= 0x4;
 
-      f_file_stream_flush(file);
-    }
-    else {
-      if (F_type_descriptor_input_d != -1) {
-        file.id = F_type_descriptor_input_d;
-        flag |= 0x80;
+        f_file_stream_flush(file);
+      }
+      else {
+        if (F_type_descriptor_input_d != -1) {
+          file.id = F_type_descriptor_input_d;
+          flag |= 0x80;
 
-        f_file_flush(file);
+          f_file_flush(file);
+        }
       }
-    }
 
-    if (flag & 0x1) {
-      file.stream = F_type_output_d;
+      if (flag & 0x1) {
+        file.stream = F_type_output_d;
 
-      f_file_stream_close(&file);
-    }
+        f_file_stream_close(&file);
+      }
 
-    if (flag & 0x2) {
-      file.stream = F_type_error_d;
+      if (flag & 0x2) {
+        file.stream = F_type_error_d;
 
-      f_file_stream_close(&file);
-    }
+        f_file_stream_close(&file);
+      }
 
-    if (flag & 0x4) {
-      file.stream = F_type_input_d;
+      if (flag & 0x4) {
+        file.stream = F_type_input_d;
 
-      f_file_stream_close(&file);
-    }
+        f_file_stream_close(&file);
+      }
 
-    if (flag & 0x10) {
-      file.id = F_type_descriptor_output_d;
+      if (flag & 0x10) {
+        file.id = F_type_descriptor_output_d;
 
-      f_file_close(&file);
-    }
+        f_file_close(&file);
+      }
 
-    if (flag & 0x20) {
-      file.id = F_type_descriptor_error_d;
+      if (flag & 0x20) {
+        file.id = F_type_descriptor_error_d;
 
-      f_file_close(&file);
-    }
+        f_file_close(&file);
+      }
 
-    if (flag & 0x40) {
-      file.id = F_type_descriptor_input_d;
+      if (flag & 0x40) {
+        file.id = F_type_descriptor_input_d;
 
-      f_file_close(&file);
+        f_file_close(&file);
+      }
     }
 
-    const f_status_t status = f_signal_close(&program->signal);
-    if (F_status_is_error(status)) return status;
+    {
+      const f_status_t status = f_signal_close(&program->signal);
+      if (F_status_is_error(status)) return status;
+    }
 
     return F_okay;
   }