Skip to content

Commit 1b58cdd

Browse files
committed
patch 7.4.2243
Problem: Warning for assigning negative value to unsigned. (Danek Duvall) Solution: Make cterm_normal_fg_gui_color and _bg_ guicolor_T, cast to long_u only when an unsigned is needed.
1 parent 17f1347 commit 1b58cdd

18 files changed

Lines changed: 66 additions & 66 deletions

src/globals.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,8 @@ EXTERN int cterm_normal_fg_color INIT(= 0);
368368
EXTERN int cterm_normal_fg_bold INIT(= 0);
369369
EXTERN int cterm_normal_bg_color INIT(= 0);
370370
#ifdef FEAT_TERMGUICOLORS
371-
EXTERN long_u cterm_normal_fg_gui_color INIT(= INVALCOLOR);
372-
EXTERN long_u cterm_normal_bg_gui_color INIT(= INVALCOLOR);
371+
EXTERN guicolor_T cterm_normal_fg_gui_color INIT(= INVALCOLOR);
372+
EXTERN guicolor_T cterm_normal_bg_gui_color INIT(= INVALCOLOR);
373373
#endif
374374

375375
#ifdef FEAT_AUTOCMD

src/gui.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4741,7 +4741,7 @@ gui_get_color(char_u *name)
47414741
int
47424742
gui_get_lightness(guicolor_T pixel)
47434743
{
4744-
long_u rgb = gui_mch_get_rgb(pixel);
4744+
long_u rgb = (long_u)gui_mch_get_rgb(pixel);
47454745

47464746
return (int)( (((rgb >> 16) & 0xff) * 299)
47474747
+ (((rgb >> 8) & 0xff) * 587)

src/gui_gtk_x11.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7020,7 +7020,7 @@ gui_mch_enable_scrollbar(scrollbar_T *sb, int flag)
70207020
/*
70217021
* Return the RGB value of a pixel as long.
70227022
*/
7023-
long_u
7023+
guicolor_T
70247024
gui_mch_get_rgb(guicolor_T pixel)
70257025
{
70267026
#if GTK_CHECK_VERSION(3,0,0)
@@ -7031,9 +7031,10 @@ gui_mch_get_rgb(guicolor_T pixel)
70317031
gdk_colormap_query_color(gtk_widget_get_colormap(gui.drawarea),
70327032
(unsigned long)pixel, &color);
70337033

7034-
return (((unsigned)color.red & 0xff00) << 8)
7034+
return (guicolor_T)(
7035+
(((unsigned)color.red & 0xff00) << 8)
70357036
| ((unsigned)color.green & 0xff00)
7036-
| (((unsigned)color.blue & 0xff00) >> 8);
7037+
| (((unsigned)color.blue & 0xff00) >> 8));
70377038
#endif
70387039
}
70397040

src/gui_mac.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5181,10 +5181,10 @@ gui_mch_start_blink(void)
51815181
/*
51825182
* Return the RGB value of a pixel as long.
51835183
*/
5184-
long_u
5184+
guicolor_T
51855185
gui_mch_get_rgb(guicolor_T pixel)
51865186
{
5187-
return (Red(pixel) << 16) + (Green(pixel) << 8) + Blue(pixel);
5187+
return (guicolor_T)((Red(pixel) << 16) + (Green(pixel) << 8) + Blue(pixel));
51885188
}
51895189

51905190

src/gui_photon.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1933,10 +1933,11 @@ gui_mch_setmouse(int x, int y)
19331933
/*
19341934
* Return the RGB value of a pixel as a long.
19351935
*/
1936-
long_u
1936+
guicolor_T
19371937
gui_mch_get_rgb(guicolor_T pixel)
19381938
{
1939-
return PgRGB(PgRedValue(pixel), PgGreenValue(pixel), PgBlueValue(pixel));
1939+
return (guicolor_T)(PgRGB(PgRedValue(pixel),
1940+
PgGreenValue(pixel), PgBlueValue(pixel)));
19401941
}
19411942

19421943
void

src/gui_w32.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2263,11 +2263,11 @@ SaveInst(HINSTANCE hInst)
22632263
/*
22642264
* Return the RGB value of a pixel as a long.
22652265
*/
2266-
long_u
2266+
guicolor_T
22672267
gui_mch_get_rgb(guicolor_T pixel)
22682268
{
2269-
return (GetRValue(pixel) << 16) + (GetGValue(pixel) << 8)
2270-
+ GetBValue(pixel);
2269+
return (guicolor_T)((GetRValue(pixel) << 16) + (GetGValue(pixel) << 8)
2270+
+ GetBValue(pixel));
22712271
}
22722272

22732273
#if defined(FEAT_GUI_DIALOG) || defined(PROTO)

src/gui_x11.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3095,7 +3095,7 @@ gui_x11_blink_cb(
30953095
/*
30963096
* Return the RGB value of a pixel as a long.
30973097
*/
3098-
long_u
3098+
guicolor_T
30993099
gui_mch_get_rgb(guicolor_T pixel)
31003100
{
31013101
XColor xc;
@@ -3105,8 +3105,8 @@ gui_mch_get_rgb(guicolor_T pixel)
31053105
xc.pixel = pixel;
31063106
XQueryColor(gui.dpy, colormap, &xc);
31073107

3108-
return ((xc.red & 0xff00) << 8) + (xc.green & 0xff00)
3109-
+ ((unsigned)xc.blue >> 8);
3108+
return (guicolor_T)(((xc.red & 0xff00) << 8) + (xc.green & 0xff00)
3109+
+ ((unsigned)xc.blue >> 8));
31103110
}
31113111

31123112
/*

src/proto/gui_gtk_x11.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ void gui_mch_menu_grey(vimmenu_T *menu, int grey);
6666
void gui_mch_menu_hidden(vimmenu_T *menu, int hidden);
6767
void gui_mch_draw_menubar(void);
6868
void gui_mch_enable_scrollbar(scrollbar_T *sb, int flag);
69-
long_u gui_mch_get_rgb(guicolor_T pixel);
69+
guicolor_T gui_mch_get_rgb(guicolor_T pixel);
7070
void gui_mch_getmouse(int *x, int *y);
7171
void gui_mch_setmouse(int x, int y);
7272
void gui_mch_mousehide(int hide);

src/proto/gui_mac.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ void gui_mch_menu_grey(vimmenu_T *menu, int grey);
7878
void gui_mch_menu_hidden(vimmenu_T *menu, int hidden);
7979
void gui_mch_draw_menubar(void);
8080
int gui_mch_get_lightness(guicolor_T pixel);
81-
long_u gui_mch_get_rgb(guicolor_T pixel);
81+
guicolor_T gui_mch_get_rgb(guicolor_T pixel);
8282
int gui_mch_get_mouse_x(void);
8383
int gui_mch_get_mouse_y(void);
8484
void gui_mch_setmouse(int x, int y);

src/proto/gui_photon.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ void mch_set_mouse_shape(int shape);
2525
void gui_mch_mousehide(int hide);
2626
void gui_mch_getmouse(int *x, int *y);
2727
void gui_mch_setmouse(int x, int y);
28-
long_u gui_mch_get_rgb(guicolor_T pixel);
28+
guicolor_T gui_mch_get_rgb(guicolor_T pixel);
2929
void gui_mch_new_colors(void);
3030
guicolor_T gui_mch_get_color(char_u *name);
3131
void gui_mch_set_fg_color(guicolor_T color);

0 commit comments

Comments
 (0)