From a8d5d408d4d18ffc1f865ca05e6e16bb01163354 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Tue, 22 Oct 2024 04:56:19 -0400 Subject: [PATCH] Fix compilation warnings * src/frame.c (tty_child_size_param): * src/frame.h (MOUSE_HL_INFO): Avoid NULL dereference warnings. (cherry picked from commit 9accfc24bcd82087d936cf7ee37470f86cac8ea7) --- src/frame.c | 16 +++++++++++----- src/frame.h | 4 +--- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/frame.c b/src/frame.c index e7d9ecbb0dd..cbae89aea71 100644 --- a/src/frame.c +++ b/src/frame.c @@ -1428,7 +1428,7 @@ tty_child_size_param (struct frame *child, Lisp_Object key, if (CONSP (val)) { /* Width and height may look like (width text-pixels - . PIXELS) on window systems. Mimic that. */ + . PIXELS) on window systems. Mimic that. */ val = XCDR (val); if (EQ (val, Qtext_pixels)) val = XCDR (val); @@ -1436,11 +1436,17 @@ tty_child_size_param (struct frame *child, Lisp_Object key, else if (FLOATP (val)) { /* Width and height may be a float, in which case - it's a multiple of the parent's value. */ + it's a multiple of the parent's value. */ struct frame *parent = FRAME_PARENT_FRAME (child); - int sz = (EQ (key, Qwidth) ? FRAME_TOTAL_COLS (parent) - : FRAME_TOTAL_LINES (parent)); - val = make_fixnum (XFLOAT_DATA (val) * sz); + eassert (parent); /* the caller ensures this, but... */ + if (parent) + { + int sz = (EQ (key, Qwidth) ? FRAME_TOTAL_COLS (parent) + : FRAME_TOTAL_LINES (parent)); + val = make_fixnum (XFLOAT_DATA (val) * sz); + } + else + val = Qnil; } if (FIXNATP (val)) diff --git a/src/frame.h b/src/frame.h index 0b7368fb29b..9a9d025e638 100644 --- a/src/frame.h +++ b/src/frame.h @@ -1018,9 +1018,7 @@ default_pixels_per_inch_y (void) #ifndef HAVE_ANDROID # define MOUSE_HL_INFO(F) \ (FRAME_WINDOW_P (F) \ - ? (FRAME_OUTPUT_DATA (F) \ - ? &FRAME_DISPLAY_INFO (F)->mouse_highlight \ - : NULL) \ + ? &FRAME_DISPLAY_INFO (F)->mouse_highlight \ : &(F)->output_data.tty->display_info->mouse_highlight) #else /* There is no "struct tty_output" on Android at all. */ -- 2.39.5