@@ -72,10 +72,10 @@ static int sdl_display_init(struct device *dev)
7272static void sdl_display_write_argb8888 (void * disp_buf ,
7373 const struct display_buffer_descriptor * desc , const void * buf )
7474{
75- __ASSERT ((4 * desc -> pitch * desc -> height ) <= desc -> buf_size ,
75+ __ASSERT ((desc -> pitch * 4U * desc -> height ) <= desc -> buf_size ,
7676 "Input buffer to small" );
7777
78- memcpy (disp_buf , buf , 4 * desc -> pitch * desc -> height );
78+ memcpy (disp_buf , buf , desc -> pitch * 4U * desc -> height );
7979}
8080
8181static void sdl_display_write_rgb888 (u8_t * disp_buf ,
@@ -86,13 +86,13 @@ static void sdl_display_write_rgb888(u8_t *disp_buf,
8686 u32_t pixel ;
8787 const u8_t * byte_ptr ;
8888
89- __ASSERT ((3 * desc -> pitch * desc -> height ) <= desc -> buf_size ,
89+ __ASSERT ((desc -> pitch * 3U * desc -> height ) <= desc -> buf_size ,
9090 "Input buffer to small" );
9191
9292 for (h_idx = 0U ; h_idx < desc -> height ; ++ h_idx ) {
9393 for (w_idx = 0U ; w_idx < desc -> width ; ++ w_idx ) {
9494 byte_ptr = (const u8_t * )buf +
95- 3 * ((h_idx * desc -> pitch ) + w_idx );
95+ ((h_idx * desc -> pitch ) + w_idx ) * 3U ;
9696 pixel = * byte_ptr << 16 ;
9797 pixel |= * (byte_ptr + 1 ) << 8 ;
9898 pixel |= * (byte_ptr + 2 );
@@ -114,7 +114,7 @@ static void sdl_display_write_mono(u8_t *disp_buf,
114114 u32_t one_color ;
115115 u8_t * disp_buf_start ;
116116
117- __ASSERT ((desc -> pitch * desc -> height ) <= (8 * desc -> buf_size ),
117+ __ASSERT ((desc -> pitch * desc -> height ) <= (desc -> buf_size * 8U ),
118118 "Input buffer to small" );
119119 __ASSERT ((desc -> height % 8 ) == 0U ,
120120 "Input buffer height not aligned per 8 pixels" );
@@ -137,12 +137,12 @@ static void sdl_display_write_mono(u8_t *disp_buf,
137137 pixel = (~one_color ) & 0x00FFFFFF ;
138138 }
139139 * ((u32_t * )disp_buf ) = pixel ;
140- disp_buf += (4 * desc -> width );
140+ disp_buf += (desc -> width * 4U );
141141 }
142142 disp_buf = disp_buf_start ;
143143 disp_buf += 4 ;
144144 }
145- disp_buf += 7 * (4 * desc -> width );
145+ disp_buf += 7 * (desc -> width * 4U );
146146 }
147147}
148148
@@ -207,11 +207,11 @@ static int sdl_display_read(const struct device *dev, const u16_t x,
207207 desc -> height , x , y );
208208
209209 __ASSERT (desc -> width <= desc -> pitch , "Pitch is smaller then width" );
210- __ASSERT ((3 * desc -> pitch * desc -> height ) <= desc -> buf_size ,
210+ __ASSERT ((desc -> pitch * 3U * desc -> height ) <= desc -> buf_size ,
211211 "Input buffer to small" );
212212
213213 return SDL_RenderReadPixels (disp_data -> renderer , & rect , 0 , buf ,
214- 4 * desc -> pitch );
214+ desc -> pitch * 4U );
215215}
216216
217217static void * sdl_display_get_framebuffer (const struct device * dev )
0 commit comments