Fix check_stdlib_usage.py libc call matching

It now matches libc usage inside statements,
and skips libc-like usage in strings or as struct members.
This commit is contained in:
Anonymous Maarten authored and Anonymous Maarten committed 2025-11-25 01:07:10 +01:00
1 parent 9896dc18e7
commit e221905195
8 files changed
+42 -33

No files matched your search

+2 -2
View File
@@ -330,7 +330,7 @@ static struct param *param_add(struct spa_list *params,
id = SPA_POD_OBJECT_ID(param);
}
p = malloc(sizeof(*p) + (param != NULL ? SPA_POD_SIZE(param) : 0));
p = malloc(sizeof(*p) + (param != NULL ? SPA_POD_SIZE(param) : 0)); // This should NOT be SDL_malloc()
if (p == NULL)
return NULL;
@@ -950,7 +950,7 @@ static void hotplug_registry_global_callback(void *object, uint32_t id,
g->permissions = permissions;
g->props = props ? PIPEWIRE_pw_properties_new_dict(props) : NULL;
g->proxy = proxy;
g->name = strdup(name);
g->name = strdup(name); // This should NOT be SDL_strdup()
spa_list_init(&g->pending_list);
spa_list_init(&g->param_list);
spa_list_append(&hotplug.global_list, &g->link);
+1 -1
View File
@@ -515,7 +515,7 @@ static void SDL_InitDynamicAPILocked(void)
const DWORD rc = GetEnvironmentVariableA(SDL_DYNAMIC_API_ENVVAR, envbuf, (DWORD) sizeof (envbuf));
char *libname = ((rc != 0) && (rc < sizeof (envbuf))) ? envbuf : NULL;
#else
char *libname = getenv(SDL_DYNAMIC_API_ENVVAR);
char *libname = getenv(SDL_DYNAMIC_API_ENVVAR); // This should NOT be SDL_getenv()
#endif
SDL_DYNAPI_ENTRYFN entry = NULL; // funcs from here by default.
+1 -1
View File
@@ -31,7 +31,7 @@ EM_JS_DEPS(sdlrunapp, "$dynCall,$stringToNewUTF8");
// even though we reference the C runtime's free() in other places, it appears
// to be inlined more aggressively in Emscripten 4, so we need a reference to
// it here, too, so the inlined Javascript doesn't fail to find it.
EMSCRIPTEN_KEEPALIVE void force_free(void *ptr) { free(ptr); }
EMSCRIPTEN_KEEPALIVE void force_free(void *ptr) { free(ptr); } // This should NOT be SDL_free()
int SDL_RunApp(int argc, char *argv[], SDL_main_func mainFunction, void * reserved)
{
+3 -3
View File
@@ -45,9 +45,9 @@ static void SDL_EMSCRIPTEN_AccelerometerCallback(const EmscriptenDeviceMotionEve
// Convert from browser specific gravity constant to SDL_STANDARD_GRAVITY.
total_gravity = 0.0;
total_gravity += fabs(event->accelerationIncludingGravityX - event->accelerationX);
total_gravity += fabs(event->accelerationIncludingGravityY - event->accelerationY);
total_gravity += fabs(event->accelerationIncludingGravityZ - event->accelerationZ);
total_gravity += SDL_fabs(event->accelerationIncludingGravityX - event->accelerationX);
total_gravity += SDL_fabs(event->accelerationIncludingGravityY - event->accelerationY);
total_gravity += SDL_fabs(event->accelerationIncludingGravityZ - event->accelerationZ);
gravity[0] = (event->accelerationIncludingGravityX - event->accelerationX) / total_gravity;
gravity[1] = (event->accelerationIncludingGravityY - event->accelerationY) / total_gravity;
+1 -1
View File
@@ -398,7 +398,7 @@ static int get_plane_id(SDL_VideoDevice *_this, unsigned int crtc_id, uint32_t p
drmModePropertyPtr p = KMSDRM_drmModeGetProperty(viddata->drm_fd,
props->props[j]);
if ((strcmp(p->name, "type") == 0) && (props->prop_values[j] == plane_type)) {
if ((SDL_strcmp(p->name, "type") == 0) && (props->prop_values[j] == plane_type)) {
/* found our plane, use that: */
found = 1;
}
+1 -1
View File
@@ -53,7 +53,7 @@ int SDL_RunApp(int argc, char *argv[], SDL_main_func mainFunction, void *reserve
forward_argc = argc;
forward_argv = (char **)malloc((argc + 1) * sizeof(char *)); // This should NOT be SDL_malloc()
for (int i = 0; i < argc; i++) {
forward_argv[i] = malloc((strlen(argv[i]) + 1) * sizeof(char)); // This should NOT be SDL_malloc()
forward_argv[i] = malloc((SDL_strlen(argv[i]) + 1) * sizeof(char)); // This should NOT be SDL_malloc()
strcpy(forward_argv[i], argv[i]);
}
forward_argv[argc] = NULL;