From db260593f12725a60972d5578237e22786a56607 Mon Sep 17 00:00:00 2001 From: Huang Qi Date: Mon, 21 Feb 2022 16:29:33 +0800 Subject: [PATCH] vncserver: Correct size calculation of rfb_setencodings_s Fix ``` video/vnc/vnc_negotiate.c:426:29: warning: shifting a negative signed value is undefined [-Wshift-negative-value] DEBUGASSERT(nrecvd >= SIZEOF_RFB_SETENCODINGS_S(0)); ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/huang/Work/nx/nuttx/include/nuttx/video/rfb.h:359:51: note: expanded from macro 'SIZEOF_RFB_SETENCODINGS_S' (sizeof(struct rfb_setencodings_s) + (((n) - 1) << 2)) ^ /home/huang/Work/nx/nuttx/include/assert.h:56:33: note: expanded from macro 'DEBUGASSERT' ~~~~~~~^~ /home/huang/Work/nx/nuttx/include/assert.h:51:37: note: expanded from macro 'ASSERT' ``` Signed-off-by: Huang Qi --- include/nuttx/video/rfb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/nuttx/video/rfb.h b/include/nuttx/video/rfb.h index 577892d325b..9eb6d63df5a 100644 --- a/include/nuttx/video/rfb.h +++ b/include/nuttx/video/rfb.h @@ -356,7 +356,7 @@ struct rfb_setencodings_s }; #define SIZEOF_RFB_SETENCODINGS_S(n) \ - (sizeof(struct rfb_setencodings_s) + (((n) - 1) << 2)) + (sizeof(struct rfb_setencodings_s) + ((n) == 0 ? -4 : ((n) - 1) << 2)) /* 6.4.3 FramebufferUpdateRequest *