Skip to content

Commit

Permalink
drivers: mark arrays of drivers as 'const'
Browse files Browse the repository at this point in the history
Each struct sr_dev_driver is writable, but the array of pointers to
those structs can be const.
  • Loading branch information
fenugrec committed Nov 24, 2023
1 parent 2037284 commit 8439f39
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/drivers.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void sr_register_dev_node(struct device_node *devnode) {
devlist_head = devnode;
}

void sr_register_dev_array(struct sr_dev_driver *driver_array[], struct device_node *node_array, unsigned num) {
void sr_register_dev_array(struct sr_dev_driver * const driver_array[], struct device_node *node_array, unsigned num) {
unsigned i;
struct device_node *dnode;

Expand Down
4 changes: 2 additions & 2 deletions src/libsigrok-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,7 @@ struct device_node {
};

/** should only be called via SR_REGISTER_DEV_DRIVER_LIST() macro */
void sr_register_dev_array(struct sr_dev_driver *driver_array[], struct device_node *node_array, unsigned num);
void sr_register_dev_array(struct sr_dev_driver * const driver_array[], struct device_node *node_array, unsigned num);

/** should only be called via SR_REGISTER_DEV_DRIVER() macro */
void sr_register_dev_node(struct device_node *devnode);
Expand Down Expand Up @@ -1178,7 +1178,7 @@ void sr_register_dev_node(struct device_node *devnode);
* @param ... Comma separated list of pointers to sr_dev_driver structs.
*/
#define SR_REGISTER_DEV_DRIVER_LIST(name, ...) \
static struct sr_dev_driver *name[] = { \
static struct sr_dev_driver * const name[] = { \
__VA_ARGS__ \
}; \
static struct device_node name##_nodes[ARRAY_SIZE(name)]; \
Expand Down

0 comments on commit 8439f39

Please sign in to comment.