From 36ba2b9a0edf1b935c3d13db41b366bc81ccebfc Mon Sep 17 00:00:00 2001 From: nhmall Date: Mon, 12 Jun 2023 13:53:34 -0400 Subject: [PATCH] fix curses build issue caused by "attr_t same as int" assumption In file included from ../win/curses/cursmisc.c:6: ../win/curses/cursmisc.c: In function 'curses_convert_attr': ../lib/pdcursesmod/curses.h:562:32: warning: overflow in conversion from 'long long unsigned int' to 'int' changes value from '2147483648' to '-2147483648' [-Woverflow] 562 | #define PDC_ATTRIBUTE_BIT( N) ((chtype)1 << (N)) | ^ ../lib/pdcursesmod/curses.h:574:27: note: in expansion of macro 'PDC_ATTRIBUTE_BIT' 574 | # define A_DIM PDC_ATTRIBUTE_BIT( PDC_CHARTEXT_BITS + 10) | ^~~~~~~~~~~~~~~~~ ../win/curses/cursmisc.c:752:23: note: in expansion of macro 'A_DIM' 752 | curses_attr = A_DIM; | ^~~~~ --- include/wincurs.h | 2 +- win/curses/cursmisc.c | 4 ++-- win/curses/cursmisc.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/wincurs.h b/include/wincurs.h index e18863b36..ce29d51a6 100644 --- a/include/wincurs.h +++ b/include/wincurs.h @@ -171,7 +171,7 @@ extern void curses_posthousekeeping(void); extern void curses_view_file(const char *filename, boolean must_exist); extern void curses_rtrim(char *str); extern long curses_get_count(int first_digit); -extern int curses_convert_attr(int attr); +extern attr_t curses_convert_attr(int attr); extern int curses_read_attrs(const char *attrs); extern char *curses_fmt_attrs(char *); extern int curses_convert_keys(int key); diff --git a/win/curses/cursmisc.c b/win/curses/cursmisc.c index 3f724f83b..6eb337eb2 100644 --- a/win/curses/cursmisc.c +++ b/win/curses/cursmisc.c @@ -729,10 +729,10 @@ curses_get_count(int first_digit) /* Convert the given NetHack text attributes into the format curses understands, and return that format mask. */ -int +attr_t curses_convert_attr(int attr) { - int curses_attr; + attr_t curses_attr; /* first, strip off control flags masked onto the display attributes (caller should have already done this...) */ diff --git a/win/curses/cursmisc.h b/win/curses/cursmisc.h index 459decb4a..76dd0ffcc 100644 --- a/win/curses/cursmisc.h +++ b/win/curses/cursmisc.h @@ -28,7 +28,7 @@ void curses_posthousekeeping(void); void curses_view_file(const char *filename, boolean must_exist); void curses_rtrim(char *str); long curses_get_count(int first_digit); -int curses_convert_attr(int attr); +attr_t curses_convert_attr(int attr); int curses_read_attrs(const char *attrs); char *curses_fmt_attrs(char *); int curses_convert_keys(int key);