Skip to contentSkip to conversation

gfxterm: check elements' properties and hadle errors.

PATCH In review Vladimir Testov 3 participants 3 messages Mar 4, 2013 – Mar 7, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gfxterm: check elements' properties and hadle errors.

GRUB does not show errors about non-existing properties or wrong values. property name and error hadling works only for global properties

This patch fixes this misbehavior.

Signature · 4 lines
With best regards,
_______________________________
Vladimir Testov, ROSA Laboratory.
www.rosalab.ru
grub-core/gfxmenu/gui_box.c +4 -0
diff -Naur grub-2.00/grub-core/gfxmenu/gui_box.c grub-patch/grub-core/gfxmenu/gui_box.c
@@ -300,6 +300,10 @@
       else
         self->id = 0;
     }
+  else
+    {
+      return GRUB_ERR_IO;
+    }
 
   return grub_errno;
 }
grub-core/gfxmenu/gui_canvas.c +4 -0
diff -Naur grub-2.00/grub-core/gfxmenu/gui_canvas.c grub-patch/grub-core/gfxmenu/gui_canvas.c
@@ -186,6 +186,10 @@
       else
         self->id = 0;
     }
+  else
+    {
+      return GRUB_ERR_IO;
+    }
   return grub_errno;
 }
 
grub-core/gfxmenu/gui_circular_progress.c +4 -0
diff -Naur grub-2.00/grub-core/gfxmenu/gui_circular_progress.c grub-patch/grub-core/gfxmenu/gui_circular_progress.c
@@ -270,6 +270,10 @@
 	grub_gfxmenu_timeout_register ((grub_gui_component_t) self,
 				       circprog_set_state);
     }
+  else
+    {
+      return GRUB_ERR_IO;
+    }
   return grub_errno;
 }
 
grub-core/gfxmenu/gui_image.c +4 -0
diff -Naur grub-2.00/grub-core/gfxmenu/gui_image.c grub-patch/grub-core/gfxmenu/gui_image.c
@@ -237,6 +237,10 @@
       else
         self->id = 0;
     }
+  else
+    {
+      return GRUB_ERR_IO;
+    }
   return grub_errno;
 }
 
grub-core/gfxmenu/gui_label.c +4 -0
diff -Naur grub-2.00/grub-core/gfxmenu/gui_label.c grub-patch/grub-core/gfxmenu/gui_label.c
@@ -231,6 +231,10 @@
 	grub_gfxmenu_timeout_register ((grub_gui_component_t) self,
 				       label_set_state);
     }
+  else
+    {
+      return GRUB_ERR_IO;
+    }
   return GRUB_ERR_NONE;
 }
 
grub-core/gfxmenu/gui_list.c +4 -0
diff -Naur grub-2.00/grub-core/gfxmenu/gui_list.c grub-patch/grub-core/gfxmenu/gui_list.c
@@ -527,6 +527,10 @@
       else
         self->id = 0;
     }
+  else
+    {
+      return GRUB_ERR_IO;
+    }
   return grub_errno;
 }
 
grub-core/gfxmenu/gui_progress_bar.c +4 -0
diff -Naur grub-2.00/grub-core/gfxmenu/gui_progress_bar.c grub-patch/grub-core/gfxmenu/gui_progress_bar.c
@@ -345,6 +345,10 @@
 	grub_gfxmenu_timeout_register ((grub_gui_component_t) self,
 				       progress_bar_set_state);
     }
+  else
+    {
+      return GRUB_ERR_IO;
+    }
   return grub_errno;
 }
 
grub-core/gfxmenu/theme_loader.c +10 -1
diff -Naur grub-2.00/grub-core/gfxmenu/theme_loader.c grub-patch/grub-core/gfxmenu/theme_loader.c
@@ -557,7 +557,16 @@
 	parse_proportional_spec (value, &component->h, &component->hfrac);
       else
 	/* General property handling.  */
-	component->ops->set_property (component, property, value);
+        {
+          grub_err_t error = component->ops->set_property (component, property, value);
+          if (error != GRUB_ERR_NONE)
+            {
+              grub_error (GRUB_ERR_IO,
+                          "%s:%d:%d unknown property or wrong value `%s'=`%s'",
+                          p->filename, p->line_num, p->col_num,
+                          property, value);
+            }
+        }
 
       grub_free (value);
       grub_free (property);
#1 lore raw

В Mon, 04 Mar 2013 15:27:51 +0400
Vladimir Testov <[email protected]> пишет:

Quoted 5 lines

GRUB does not show errors about non-existing properties or wrong values. property name and error hadling works only for global properties

This patch fixes this misbehavior.

I find diff -p... generally more readable by providing context around changes. May be my personal preference.

Quoted 7 lines
grub-core/gfxmenu/theme_loader.c +0 -1
@@ -557,7 +557,16 @@
 	parse_proportional_spec (value, &component->h, &component->hfrac);
       else
 	/* General property handling.  */
-	component->ops->set_property (component, property, value);

grub-core/gfxmenu/theme_loader.c line 569

Quoted 10 lines
grub-core/gfxmenu/theme_loader.c +10 -0
+        {
+          grub_err_t error = component->ops->set_property (component, property, value);
+          if (error != GRUB_ERR_NONE)
+            {
+              grub_error (GRUB_ERR_IO,
+                          "%s:%d:%d unknown property or wrong value `%s'=`%s'",
+                          p->filename, p->line_num, p->col_num,
+                          property, value);
+            }
+        }

This loses original OOM error if it was returned. May be make it return true/false and check if grub_errno is set on false. Not sure.

Do you have any real problem to solve? I wonder if these errors are visible to user at all; if not, setting them does not really buy anything.

#2 lore raw
In reply to Vladimir Testov

grub-core/gfxmenu/gui_box.c line 306

Quoted 4 lines · Vladimir Testov
grub-core/gfxmenu/gui_box.c +4 -0
+  else
+    {
+      return GRUB_ERR_IO;
+    }

This is not a correct error handling. You should never return an error without calling grub_error. Also in all these contexts you handle the cases of unknown property name. I don't feel like refusing to load a theme because of unknown property is a good idea. This would i.a. exclude older GRUB versions for newer themes even if property in question is minor in meaning. Compare this to a browser refusing to show a page because of unknown tag attribute. Also GRUB_ERR_IO hardly describes a condition of unknown property.