[PATCH V1] um: Fix compilation warnings

Srinivasarao Pathipati quic_c_spathi at quicinc.com
Tue Feb 14 13:30:43 PST 2023


Use dynamic allocation in sig_handler_common() and in
timer_real_alarm_handler() to fix below warnings and build
failures where CONFIG_WERROR is enabled.

arch/um/os-Linux/signal.c: In function ‘sig_handler_common’:
arch/um/os-Linux/signal.c:51:1: error: the frame size of 2960 bytes is larger than 1024 bytes [-Werror=frame-larger-than=]
 }
 ^
arch/um/os-Linux/signal.c: In function ‘timer_real_alarm_handler’:
arch/um/os-Linux/signal.c:95:1: error: the frame size of 2960 bytes is larger than 1024 bytes [-Werror=frame-larger-than=]
 }

Signed-off-by: Srinivasarao Pathipati <quic_c_spathi at quicinc.com>
---
 arch/um/os-Linux/signal.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/arch/um/os-Linux/signal.c b/arch/um/os-Linux/signal.c
index 24a403a..9de8826 100644
--- a/arch/um/os-Linux/signal.c
+++ b/arch/um/os-Linux/signal.c
@@ -32,23 +32,25 @@ void (*sig_info[NSIG])(int, struct siginfo *, struct uml_pt_regs *) = {
 
 static void sig_handler_common(int sig, struct siginfo *si, mcontext_t *mc)
 {
-	struct uml_pt_regs r;
+	struct uml_pt_regs *r;
 	int save_errno = errno;
 
-	r.is_user = 0;
+	r = malloc(sizeof(struct uml_pt_regs));
+	r->is_user = 0;
 	if (sig == SIGSEGV) {
 		/* For segfaults, we want the data from the sigcontext. */
-		get_regs_from_mc(&r, mc);
-		GET_FAULTINFO_FROM_MC(r.faultinfo, mc);
+		get_regs_from_mc(r, mc);
+		GET_FAULTINFO_FROM_MC(r->faultinfo, mc);
 	}
 
 	/* enable signals if sig isn't IRQ signal */
 	if ((sig != SIGIO) && (sig != SIGWINCH))
 		unblock_signals_trace();
 
-	(*sig_info[sig])(sig, si, &r);
+	(*sig_info[sig])(sig, si, r);
 
 	errno = save_errno;
+	free(r);
 }
 
 /*
@@ -99,13 +101,15 @@ void sig_handler(int sig, struct siginfo *si, mcontext_t *mc)
 
 static void timer_real_alarm_handler(mcontext_t *mc)
 {
-	struct uml_pt_regs regs;
+	struct uml_pt_regs *regs;
 
+	regs = malloc(sizeof(struct uml_pt_regs));
 	if (mc != NULL)
-		get_regs_from_mc(&regs, mc);
+		get_regs_from_mc(regs, mc);
 	else
-		memset(&regs, 0, sizeof(regs));
-	timer_handler(SIGALRM, NULL, &regs);
+		memset(regs, 0, sizeof(struct uml_pt_regs));
+	timer_handler(SIGALRM, NULL, regs);
+	free(regs);
 }
 
 void timer_alarm_handler(int sig, struct siginfo *unused_si, mcontext_t *mc)
-- 
2.7.4




More information about the linux-um mailing list