Cleanups - try to remove stdio.h include where possible

This commit is contained in:
libretroadmin 2023-01-21 22:25:38 +01:00
parent c3fe980a1d
commit 01c3684b10
17 changed files with 84 additions and 92 deletions

View File

@ -14,7 +14,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <malloc.h>
#include <math.h>

View File

@ -13,7 +13,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <math.h>
#include <malloc.h>

View File

@ -15,7 +15,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <malloc.h>
#include <math.h>

View File

@ -14,7 +14,7 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <malloc.h>
#include <math.h>

View File

@ -16,11 +16,9 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <libretro.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <boolean.h>
@ -140,8 +138,7 @@ bitmapfont_lut_t *bitmapfont_10x10_load(unsigned language)
num_glyphs = (glyph_max - glyph_min) + 1;
/* Initialise font struct */
font = (bitmapfont_lut_t*)calloc(1, sizeof(bitmapfont_lut_t));
if (!font)
if (!(font = (bitmapfont_lut_t*)calloc(1, sizeof(bitmapfont_lut_t))))
goto error;
font->glyph_min = glyph_min;
@ -150,8 +147,7 @@ bitmapfont_lut_t *bitmapfont_10x10_load(unsigned language)
/* Note: Need to use a calloc() here, otherwise
* we'll get undefined behaviour when calling
* bitmapfont_free_lut() if the following loop fails */
font->lut = (bool**)calloc(1, num_glyphs * sizeof(bool*));
if (!font->lut)
if (!(font->lut = (bool**)calloc(1, num_glyphs * sizeof(bool*))))
goto error;
/* Loop over all possible characters */

View File

@ -17,11 +17,9 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <libretro.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <boolean.h>
@ -70,51 +68,46 @@ bitmapfont_lut_t *bitmapfont_6x10_load(unsigned language)
* specified language */
switch (language)
{
/* Needed individually for any non-Latin languages */
case RETRO_LANGUAGE_ENGLISH:
{
font_file = FONT_6X10_FILE_ENG;
font_size = FONT_6X10_SIZE_ENG;
glyph_min = FONT_6X10_GLYPH_MIN_ENG;
glyph_max = FONT_6X10_GLYPH_MAX_ENG;
break;
}
/* All Latin alphabet languages go here */
case RETRO_LANGUAGE_FRENCH:
case RETRO_LANGUAGE_SPANISH:
case RETRO_LANGUAGE_GERMAN:
case RETRO_LANGUAGE_ITALIAN:
case RETRO_LANGUAGE_DUTCH:
case RETRO_LANGUAGE_PORTUGUESE_BRAZIL:
case RETRO_LANGUAGE_PORTUGUESE_PORTUGAL:
case RETRO_LANGUAGE_ESPERANTO:
case RETRO_LANGUAGE_POLISH:
case RETRO_LANGUAGE_VIETNAMESE:
case RETRO_LANGUAGE_TURKISH:
case RETRO_LANGUAGE_SLOVAK:
case RETRO_LANGUAGE_ASTURIAN:
case RETRO_LANGUAGE_FINNISH:
case RETRO_LANGUAGE_INDONESIAN:
case RETRO_LANGUAGE_SWEDISH:
case RETRO_LANGUAGE_CZECH:
case RETRO_LANGUAGE_HUNGARIAN:
/* These languages are not yet added
case RETRO_LANGUAGE_ROMANIAN:
case RETRO_LANGUAGE_CROATIAN:
case RETRO_LANGUAGE_SERBIAN:
case RETRO_LANGUAGE_WELSH:
*/
{
font_file = FONT_6X10_FILE_LSE;
font_size = FONT_6X10_SIZE_LSE;
glyph_min = FONT_6X10_GLYPH_MIN_LSE;
glyph_max = FONT_6X10_GLYPH_MAX_LSE;
break;
}
default:
break;
/* Needed individually for any non-Latin languages */
case RETRO_LANGUAGE_ENGLISH:
font_file = FONT_6X10_FILE_ENG;
font_size = FONT_6X10_SIZE_ENG;
glyph_min = FONT_6X10_GLYPH_MIN_ENG;
glyph_max = FONT_6X10_GLYPH_MAX_ENG;
break;
/* All Latin alphabet languages go here */
case RETRO_LANGUAGE_FRENCH:
case RETRO_LANGUAGE_SPANISH:
case RETRO_LANGUAGE_GERMAN:
case RETRO_LANGUAGE_ITALIAN:
case RETRO_LANGUAGE_DUTCH:
case RETRO_LANGUAGE_PORTUGUESE_BRAZIL:
case RETRO_LANGUAGE_PORTUGUESE_PORTUGAL:
case RETRO_LANGUAGE_ESPERANTO:
case RETRO_LANGUAGE_POLISH:
case RETRO_LANGUAGE_VIETNAMESE:
case RETRO_LANGUAGE_TURKISH:
case RETRO_LANGUAGE_SLOVAK:
case RETRO_LANGUAGE_ASTURIAN:
case RETRO_LANGUAGE_FINNISH:
case RETRO_LANGUAGE_INDONESIAN:
case RETRO_LANGUAGE_SWEDISH:
case RETRO_LANGUAGE_CZECH:
case RETRO_LANGUAGE_HUNGARIAN:
#if 0
/* These languages are not yet added */
case RETRO_LANGUAGE_ROMANIAN:
case RETRO_LANGUAGE_CROATIAN:
case RETRO_LANGUAGE_SERBIAN:
case RETRO_LANGUAGE_WELSH:
#endif
font_file = FONT_6X10_FILE_LSE;
font_size = FONT_6X10_SIZE_LSE;
glyph_min = FONT_6X10_GLYPH_MIN_LSE;
glyph_max = FONT_6X10_GLYPH_MAX_LSE;
break;
default:
break;
}
/* Sanity check: should only trigger on bug */

View File

@ -15,13 +15,11 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <retro_miscellaneous.h>
#include "../../config.def.h"
#include "../input_driver.h"
#include "../input_keymaps.h"
#include "../drivers_keyboard/keyboard_event_dos.h"

View File

@ -1,11 +1,10 @@
#include <stdio.h>
#include <stdint.h>
#include "../led_driver.h"
#include "../led_defines.h"
#include "../../input/input_overlay.h"
#include "../../configuration.h"
#include "../../retroarch.h"
typedef struct
{

View File

@ -1,4 +1,4 @@
#include <stdio.h>
#include <stdint.h>
#include "../led_driver.h"
#include "../led_defines.h"

View File

@ -1,12 +1,12 @@
#include <stdio.h>
#include <X11/Xlib.h>
#include <X11/XKBlib.h>
#include "../led_driver.h"
#include "../led_defines.h"
#include "../../configuration.h"
#include "../../retroarch.h"
#include <X11/Xlib.h>
#include <X11/XKBlib.h>
/* Keys when setting in XKeyboardControl.led */
#define XK_NUMLOCK 2
@ -49,33 +49,38 @@ static keyboard_led_t *x11kb_cur = &x11kb_curins;
static int get_led(int led)
{
Display *dpy = XOpenDisplay(0);
XKeyboardState state;
Display *dpy = XOpenDisplay(0);
XGetKeyboardControl(dpy, &state);
XCloseDisplay(dpy);
switch (led)
{
case XK_NUMLOCK:
return (state.led_mask & XM_NUMLOCK) ? 1 : 0;
if (state.led_mask & XM_NUMLOCK)
return 1;
break;
case XK_CAPSLOCK:
return (state.led_mask & XM_CAPSLOCK) ? 1 : 0;
if (state.led_mask & XM_CAPSLOCK)
return 1;
break;
case XK_SCROLLLOCK:
return (state.led_mask & XM_SCROLLLOCK) ? 1 : 0;
if (state.led_mask & XM_SCROLLLOCK)
return 1;
break;
default:
break;
}
return 0;
}
static void set_led(int led, int state)
{
Display *dpy = XOpenDisplay(0);
XKeyboardControl values;
values.led = led;
Display *dpy = XOpenDisplay(0);
values.led = led;
values.led_mode = state ? LedModeOn : LedModeOff;
XChangeKeyboardControl(dpy, KBLed | KBLedMode, &values);
XCloseDisplay(dpy);
@ -116,9 +121,9 @@ static void keyboard_init(void)
for (i = 0; i < MAX_LEDS; i++)
{
x11kb_cur->setup[i] = keyboard_led(i, -1);
x11kb_cur->state[i] = -1;
x11kb_cur->map[i] = settings->uints.led_map[i];
x11kb_cur->setup[i] = keyboard_led(i, -1);
x11kb_cur->state[i] = -1;
x11kb_cur->map[i] = settings->uints.led_map[i];
if (x11kb_cur->map[i] < 0)
x11kb_cur->map[i] = i;
}

View File

@ -16,9 +16,9 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <boolean.h>

View File

@ -16,9 +16,9 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <boolean.h>

View File

@ -16,9 +16,9 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <boolean.h>

View File

@ -15,9 +15,9 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <string/stdstring.h>

View File

@ -15,9 +15,10 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <string/stdstring.h>

View File

@ -15,9 +15,10 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <string/stdstring.h>
@ -27,7 +28,6 @@
#include "tasks_internal.h"
#include "../configuration.h"
#include "../msg_hash.h"
#include "../file_path_special.h"
#include "../playlist.h"

View File

@ -15,17 +15,17 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdint.h>
#include <stddef.h>
#include <string.h>
#include <time.h>
#include <boolean.h>
#ifdef HAVE_CONFIG_H
#include "../config.h"
#endif
#include <stdio.h>
#include <stddef.h>
#include <time.h>
#include <boolean.h>
#include <stdint.h>
#include <string.h>
#include <file/file_path.h>
#include <compat/strl.h>
#include <string/stdstring.h>