All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] Decrease minimal gfxterm size to 10x6
@ 2024-05-16 19:34 Vladimir Serbinenko
  2024-05-16 19:34 ` [PATCH 2/3] Don't attempt to do terminal functions on non-functional gfxterm Vladimir Serbinenko
  2024-05-16 19:34 ` [PATCH 3/3] grub_unicode_destroy_glyph: Don't destroy NULL glyph Vladimir Serbinenko
  0 siblings, 2 replies; 3+ messages in thread
From: Vladimir Serbinenko @ 2024-05-16 19:34 UTC (permalink / raw)
  To: grub-devel; +Cc: Vladimir Serbinenko

10x6 is still marginally usable. Erroring out may leave user without any console

Signed-off-by: Vladimir Serbinenko <phcoder@gmail.com>
---
 grub-core/term/gfxterm.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/grub-core/term/gfxterm.c b/grub-core/term/gfxterm.c
index addad5ee2..e8734a388 100644
--- a/grub-core/term/gfxterm.c
+++ b/grub-core/term/gfxterm.c
@@ -234,12 +234,13 @@ grub_virtual_screen_setup (unsigned int x, unsigned int y,
 
   /*
    * There must be a minimum number of rows and columns for the screen to
-   * make sense. Arbitrarily pick half of 80x24. If either dimensions is 0
+   * make sense. Arbitrarily pick 10x6. If either dimensions is 0
    * we would allocate 0 bytes for the text_buffer.
    */
-  if (virtual_screen.columns < 40 || virtual_screen.rows < 12)
+  if (virtual_screen.columns < 10 || virtual_screen.rows < 6)
     return grub_error (GRUB_ERR_BAD_FONT,
-		       "font: glyphs too large to fit on screen");
+		       "font: glyphs too large to fit on screen (%dx%d)",
+		       virtual_screen.columns, virtual_screen.rows);
 
   /* Allocate memory for text buffer.  */
   virtual_screen.text_buffer =
-- 
2.39.2


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/3] Don't attempt to do terminal functions on non-functional gfxterm
  2024-05-16 19:34 [PATCH 1/3] Decrease minimal gfxterm size to 10x6 Vladimir Serbinenko
@ 2024-05-16 19:34 ` Vladimir Serbinenko
  2024-05-16 19:34 ` [PATCH 3/3] grub_unicode_destroy_glyph: Don't destroy NULL glyph Vladimir Serbinenko
  1 sibling, 0 replies; 3+ messages in thread
From: Vladimir Serbinenko @ 2024-05-16 19:34 UTC (permalink / raw)
  To: grub-devel; +Cc: Vladimir Serbinenko

Attempting to do anything easily leads to a crash

Signed-off-by: Vladimir Serbinenko <phcoder@gmail.com>
---
 grub-core/term/gfxterm.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/grub-core/term/gfxterm.c b/grub-core/term/gfxterm.c
index e8734a388..6513a529b 100644
--- a/grub-core/term/gfxterm.c
+++ b/grub-core/term/gfxterm.c
@@ -1038,6 +1038,9 @@ static void
 grub_gfxterm_gotoxy (struct grub_term_output *term __attribute__ ((unused)),
 		     struct grub_term_coordinate pos)
 {
+  if (!virtual_screen.functional)
+    return;
+
   if (pos.x >= virtual_screen.columns)
     pos.x = virtual_screen.columns - 1;
 
@@ -1072,6 +1075,9 @@ grub_gfxterm_cls (struct grub_term_output *term)
 {
   grub_video_color_t color;
 
+  if (!virtual_screen.functional)
+    return;
+
   /* Clear virtual screen.  */
   grub_virtual_screen_cls (term);
 
@@ -1118,6 +1124,9 @@ static void
 grub_gfxterm_setcursor (struct grub_term_output *term __attribute__ ((unused)),
 			int on)
 {
+  if (!virtual_screen.functional)
+    return;
+
   if (virtual_screen.cursor_state != on)
     {
       if (virtual_screen.cursor_state)
@@ -1132,6 +1141,9 @@ grub_gfxterm_setcursor (struct grub_term_output *term __attribute__ ((unused)),
 static void
 grub_gfxterm_refresh (struct grub_term_output *term __attribute__ ((unused)))
 {
+  if (!virtual_screen.functional)
+    return;
+
   real_scroll ();
 
   /* Redraw only changed regions.  */
-- 
2.39.2


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 3/3] grub_unicode_destroy_glyph: Don't destroy NULL glyph
  2024-05-16 19:34 [PATCH 1/3] Decrease minimal gfxterm size to 10x6 Vladimir Serbinenko
  2024-05-16 19:34 ` [PATCH 2/3] Don't attempt to do terminal functions on non-functional gfxterm Vladimir Serbinenko
@ 2024-05-16 19:34 ` Vladimir Serbinenko
  1 sibling, 0 replies; 3+ messages in thread
From: Vladimir Serbinenko @ 2024-05-16 19:34 UTC (permalink / raw)
  To: grub-devel; +Cc: Vladimir Serbinenko

This is more in-line with free() behaviour.

Signed-off-by: Vladimir Serbinenko <phcoder@gmail.com>
---
 include/grub/unicode.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/grub/unicode.h b/include/grub/unicode.h
index 9360b0b97..9a3a1d02a 100644
--- a/include/grub/unicode.h
+++ b/include/grub/unicode.h
@@ -281,6 +281,8 @@ grub_unicode_get_comb (const struct grub_unicode_glyph *in)
 static inline void
 grub_unicode_destroy_glyph (struct grub_unicode_glyph *glyph)
 {
+  if (!glyph)
+    return;
   if (glyph->ncomb > ARRAY_SIZE (glyph->combining_inline))
     grub_free (glyph->combining_ptr);
   glyph->ncomb = 0;
-- 
2.39.2


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-05-16 19:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-16 19:34 [PATCH 1/3] Decrease minimal gfxterm size to 10x6 Vladimir Serbinenko
2024-05-16 19:34 ` [PATCH 2/3] Don't attempt to do terminal functions on non-functional gfxterm Vladimir Serbinenko
2024-05-16 19:34 ` [PATCH 3/3] grub_unicode_destroy_glyph: Don't destroy NULL glyph Vladimir Serbinenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.