fix: declare all slot functions in slot.h to prevent 64-bit pointer truncation

fc_slot_create, fc_slot_destroy, fc_slot_open, fc_slot_close, and
fc_slot_write_frame were defined in slot.c but never declared in slot.h.
Any translation unit calling them without seeing a proper prototype
would fall back to implicit int return (32 bits), truncating 64-bit
pointers and causing SIGSEGV on dereference.

This affected framecache.c (POST /slots → fc_slot_create, DELETE
→ fc_slot_destroy) and other callers.
This commit is contained in:
Wild Dragon Dev 2026-06-03 20:15:54 +00:00
parent 2198199a9f
commit dc66833247

View file

@ -68,6 +68,19 @@ typedef struct {
_Static_assert(sizeof(fc_frame_t) == FC_FRAME_HDR_SIZE, _Static_assert(sizeof(fc_frame_t) == FC_FRAME_HDR_SIZE,
"fc_frame_t header must be exactly FC_FRAME_HDR_SIZE bytes"); "fc_frame_t header must be exactly FC_FRAME_HDR_SIZE bytes");
/* Function declarations */
struct fc_slot *fc_slot_create(const char *slot_id,
uint32_t width, uint32_t height,
uint32_t fps_num, uint32_t fps_den,
uint32_t pixel_format,
const char *source_type);
void fc_slot_destroy(struct fc_slot *s);
struct fc_slot *fc_slot_open(const char *slot_id);
void fc_slot_close(struct fc_slot *s);
void fc_slot_write_frame(struct fc_slot *s,
const uint8_t *data, uint32_t size,
uint64_t pts_us);
/* Accessor functions — inline now that struct fc_slot is defined above */ /* Accessor functions — inline now that struct fc_slot is defined above */
static inline fc_header_t *fc_slot_header(struct fc_slot *s) { return (fc_header_t *)s->base; } static inline fc_header_t *fc_slot_header(struct fc_slot *s) { return (fc_header_t *)s->base; }
static inline const char *fc_slot_id(struct fc_slot *s) { return s->slot_id; } static inline const char *fc_slot_id(struct fc_slot *s) { return s->slot_id; }