Skip to content

Commit 18bb14a

Browse files
committed
chore(cleanup): ensure -std=c99 -Wall compiles with no warnings
Had some redundant type declarations, but otherwise pretty clean. Signed-off-by: Steven Noonan <steven@uplinklabs.net>
1 parent c38da98 commit 18bb14a

3 files changed

Lines changed: 11 additions & 8 deletions

File tree

src/generator/c/templates/header.h.j2

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,12 +306,15 @@ extern {{ fs.context_name }} gloam_{{ fs.spec_name }}_context;
306306

307307
/* ---- API declarations ---------------------------------------------------- */
308308

309+
#ifndef GLOAM_DEFINED_CALLBACK_TYPES_
310+
#define GLOAM_DEFINED_CALLBACK_TYPES_
309311
/* Opaque function pointer type — the common return type for all load
310312
callbacks. Callers cast to the specific PFN type they need. */
311313
typedef void (*GloamAPIProc)(void);
312314

313315
/* Load function pointer type (GL / EGL / GLX / WGL). */
314316
typedef GloamAPIProc (*GloamLoadFunc)(const char *name);
317+
#endif
315318
{%- if fs.is_vulkan %}
316319
/* Vulkan command scope — controls which proc-addr entry point the load
317320
callback should use. Must match the definition in impl_util.j2. */
@@ -402,3 +405,4 @@ void gloamLoaderResetVulkan(void);
402405
#endif /* _WIN32 */
403406
{% endif %}
404407
#endif /* GLOAM_{{ guard }} */
408+

src/generator/c/templates/impl_util.j2

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,6 @@
1919
#define GLOAM_ARRAYSIZE(x) (sizeof(x) / sizeof((x)[0]))
2020
#define GLOAM_UNUSED(x) ((void)(x))
2121

22-
/* Opaque function pointer type — the common return type for all load
23-
callbacks. Callers cast to the specific PFN type they need. */
24-
typedef void (*GloamAPIProc)(void);
25-
26-
/* Load function pointer type: plain proc-addr callback (GL / EGL / GLX / WGL). */
27-
typedef GloamAPIProc (*GloamLoadFunc)(const char *name);
28-
2922
/* Contiguous run of pfnArray slots belonging to one feature or extension.
3023
Used by the range-based PFN loading loop. */
3124
typedef struct {

src/generator/c/templates/source.c.j2

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
offset table for O(1) indexing. This avoids one pointer (8 bytes on 64-bit)
5252
plus one relocation entry (~24 bytes in PIC builds) per command compared to
5353
the traditional const char * const [] approach. */
54-
#define kFnCount_{{ fs.spec_name | spec_display }} {{ fs.commands | length }}
54+
static const uint32_t kFnCount_{{ fs.spec_name | spec_display }} = {{ fs.commands | length }};
5555

5656
static const char kFnNameData_{{ fs.spec_name | spec_display }}[] =
5757
{%- for cmd in fs.commands %}
@@ -647,6 +647,7 @@ static int gloam_{{ fs.spec_name }}_find_core_{{ api }}({{ u.ctx_arg(', ') }}EGL
647647
int gloamLoad{{ api | api_display }}Context({{ u.ctx_arg(', ') }}GloamLoadFunc getProcAddr) {
648648
int version;
649649
uint32_t i;
650+
GLOAM_UNUSED(kFnCount_{{ fs.spec_name | spec_display }});
650651

651652
memset(context, 0, sizeof(*context));
652653

@@ -687,6 +688,7 @@ int gloamLoad{{ api | api_display }}(GloamLoadFunc getProcAddr) {
687688
int gloamLoad{{ api | api_display }}Context({{ u.ctx_arg(', ') }}EGLDisplay display, GloamLoadFunc getProcAddr) {
688689
int version;
689690
uint32_t i;
691+
GLOAM_UNUSED(kFnCount_{{ fs.spec_name | spec_display }});
690692

691693
memset(context, 0, sizeof(*context));
692694

@@ -766,6 +768,8 @@ int gloamLoad{{ api | api_display }}(Display *display, int screen, GloamLoadFunc
766768
int gloamLoad{{ api | api_display }}Context({{ u.ctx_arg(', ') }}HDC hdc, GloamLoadFunc getProcAddr) {
767769
int version;
768770
uint32_t i;
771+
GLOAM_UNUSED(kFnCount_{{ fs.spec_name | spec_display }});
772+
769773
memset(context, 0, sizeof(*context));
770774

771775
/* WGL mandatory extensions must be loaded first for extension detection. */
@@ -835,6 +839,7 @@ int gloamLoadVulkanContextUserPtr({{ u.ctx_arg(', ') }}VkInstance instance,
835839
GloamVkUserptrLoadFunc load, void *userptr) {
836840
int version;
837841
uint32_t i;
842+
GLOAM_UNUSED(kFnCount_{{ fs.spec_name | spec_display }});
838843
GLOAM_UNUSED(instance);
839844
GLOAM_UNUSED(device);
840845

@@ -901,3 +906,4 @@ int gloamLoadVulkan(VkInstance instance, VkPhysicalDevice physical_device, VkDev
901906
{% elif fs.spec_name == "wgl" -%}
902907
#endif /* _WIN32 */
903908
{% endif %}
909+

0 commit comments

Comments
 (0)