Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check resource types passed to resource-type-specific functions #35

Open
prajnoha opened this issue Jan 13, 2020 · 0 comments
Open

Check resource types passed to resource-type-specific functions #35

prajnoha opened this issue Jan 13, 2020 · 0 comments

Comments

@prajnoha
Copy link
Member

prajnoha commented Jan 13, 2020

SID uses "resources" for code encapsulation, grouping, hierarchy and generic handling. Besides generic and shared resource-handling functions, each resource can have additional dedicated interface functions which accept a resource as an argument (of sid_resource_t * type). All these functions should check whether the type of the resource passed in is correct and error out if not (so we need to check the internal type field in sid_resource_t instance).

For example a function where we expect only a concrete single type of resource:

sid_resource_t *worker_control_get_idle_worker(sid_resource_t *worker_control_res);

The worker_control_res here must be an instance of sid_resource_type_worker_control only.

Another example where we allow two types of resources:

const char *worker_control_get_worker_id(sid_resource_t *res);

The res must be an instance of either sid_resource_type_worker or sid_resource_type_worker_proxy.

Similar checks should be done for any other resource which has such additional type-specific interface.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant