Skip to content

Commit 6a8c0e9

Browse files
committed
to_squash: Add offset determining
1 parent f89a074 commit 6a8c0e9

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

src/ctl/ctl.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,14 @@ int umfCtlExec(const char *name, void *ctx, void *arg) {
9999
* ctl_find_node -- (internal) searches for a matching entry point in the
100100
* provided nodes
101101
*
102+
* Name offset is used to return the offset of the name in the query string.
102103
* The caller is responsible for freeing all of the allocated indexes,
103104
* regardless of the return value.
104105
*/
105106
static const struct ctl_node *ctl_find_node(const struct ctl_node *nodes,
106107
const char *name,
107-
struct ctl_index_utlist *indexes) {
108+
struct ctl_index_utlist *indexes,
109+
int *name_offset) {
108110
const struct ctl_node *n = NULL;
109111
char *sptr = NULL;
110112
char *parse_str = Strdup(name);
@@ -119,6 +121,7 @@ static const struct ctl_node *ctl_find_node(const struct ctl_node *nodes,
119121
* in the main ctl tree.
120122
*/
121123
while (node_name != NULL) {
124+
*name_offset = node_name - parse_str;
122125
if (n != NULL && n->type == CTL_NODE_SUBTREE) {
123126
break;
124127
}
@@ -362,13 +365,15 @@ int ctl_query(struct ctl *ctl, void *ctx, enum ctl_query_source source,
362365
}
363366

364367
int ret = -1;
368+
int name_offset = 0;
365369

366-
const struct ctl_node *n = ctl_find_node(CTL_NODE(global), name, indexes);
370+
const struct ctl_node *n =
371+
ctl_find_node(CTL_NODE(global), name, indexes, &name_offset);
367372

368373
if (n == NULL && ctl) {
369374
ctl_delete_indexes(indexes);
370375
indexes = NULL;
371-
n = ctl_find_node(ctl->root, name, indexes);
376+
n = ctl_find_node(ctl->root, name, indexes, &name_offset);
372377
}
373378

374379
if (n == NULL ||

src/provider/provider_os_memory.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,14 @@ CTL_READ_HANDLER(ipc_enabled)(void *ctx, enum ctl_query_source source,
185185
return 0;
186186
}
187187

188-
static const struct ctl_node CTL_NODE(by_handle)[] = {CTL_LEAF_RO(ipc_enabled),
189-
CTL_NODE_END};
188+
// static const struct ctl_node CTL_NODE(by_handle)[] = {CTL_LEAF_RO(ipc_enabled),
189+
// CTL_NODE_END};
190+
191+
static const struct ctl_node CTL_LEAF_RO(ipc_enabled)[];
190192

191193
void initialize_os_ctl(void) {
192194
os_memory_ctl_root = ctl_new();
193-
CTL_REGISTER_MODULE(os_memory_ctl_root, by_handle);
195+
CTL_REGISTER_MODULE(os_memory_ctl_root, ipc_enabled);
194196
}
195197

196198
static void os_store_last_native_error(int32_t native_error, int errno_value) {

0 commit comments

Comments
 (0)