Project

General

Profile

Actions

Bug #6263

open

impossible to detect wrong callbacks being registered / osmo_io_ops union

Added by laforge 6 months ago. Updated 6 months ago.

Status:
In Progress
Priority:
Low
Assignee:
Category:
-
Target version:
-
Start date:
11/20/2023
Due date:
% Done:

40%

Spec Reference:

Description

As I just had to learn the hard way, it's possible to create an osmo_io_fd using osmo_iofd_setup in one mode (e.g. OSMO_IO_FD_MODE_READ_WRITE) but the register an osmo_io_ops with wrong call-backs (e.g. recvfrom/sendto). Given that it's a union, there's nothing we can do at runtime to detect such an error and ASSERT or the like.

We'd either have to break ABI by introducing a "enum osmo_io_fd_mode" member in the struct, or we'd have to expand all those unions into a struct. This way we can see which function pointers are NULL and non-NULL and hence determine if the right call-backs for the given mode were set.

Any ideas/comments?

Actions

Also available in: Atom PDF

Add picture from clipboard (Maximum size: 48.8 MB)