summaryrefslogtreecommitdiffstats
path: root/source3/utils
diff options
context:
space:
mode:
authorChris Davis <cd.rattan@gmail.com>2014-06-14 14:13:10 -0700
committerMichael Adam <obnox@samba.org>2014-10-01 14:32:08 +0200
commitc85cc6b8360284c64d60ff4d09ca8d5e03188f7b (patch)
tree6282cb1d36ab597b0a02df3ff9b90614b7b73fec /source3/utils
parentd38eba5244d0615994249070adee1f3df4c0d4aa (diff)
downloadsamba-c85cc6b8360284c64d60ff4d09ca8d5e03188f7b.tar.gz
samba-c85cc6b8360284c64d60ff4d09ca8d5e03188f7b.tar.xz
samba-c85cc6b8360284c64d60ff4d09ca8d5e03188f7b.zip
regedit: use talloc typesafety features
Signed-off-by: Chris Davis <cd.rattan@gmail.com> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'source3/utils')
-rw-r--r--source3/utils/regedit_treeview.c31
-rw-r--r--source3/utils/regedit_valuelist.c20
2 files changed, 33 insertions, 18 deletions
diff --git a/source3/utils/regedit_treeview.c b/source3/utils/regedit_treeview.c
index ee6b631521..47765c16de 100644
--- a/source3/utils/regedit_treeview.c
+++ b/source3/utils/regedit_treeview.c
@@ -289,8 +289,8 @@ void tree_view_set_current_node(struct tree_view *view, struct tree_node *node)
struct tree_node *tree_view_get_current_node(struct tree_view *view)
{
- return discard_const_p(struct tree_node,
- multilist_get_current_row(view->list));
+ const void *row = multilist_get_current_row(view->list);
+ return talloc_get_type_abort(row, struct tree_node);
}
void tree_view_driver(struct tree_view *view, int c)
@@ -340,28 +340,36 @@ static const char *tv_get_column_header(const void *data, unsigned col)
static const void *tv_get_first_row(const void *data)
{
- return data;
+ if (data == NULL) {
+ return NULL;
+ }
+
+ return talloc_get_type_abort(data, struct tree_node);
}
static const void *tv_get_next_row(const void *data, const void *row)
{
- const struct tree_node *node = row;
- SMB_ASSERT(node != NULL);
+ const struct tree_node *node;
+ SMB_ASSERT(row != NULL);
+ node = talloc_get_type_abort(row, struct tree_node);
return node->next;
}
static const void *tv_get_prev_row(const void *data, const void *row)
{
- const struct tree_node *node = row;
- SMB_ASSERT(node != NULL);
+ const struct tree_node *node;
+ SMB_ASSERT(row != NULL);
+ node = talloc_get_type_abort(row, struct tree_node);
return node->previous;
}
static const char *tv_get_item_prefix(const void *row, unsigned col)
{
- struct tree_node *node = discard_const_p(struct tree_node, row);
+ struct tree_node *node;
+
SMB_ASSERT(col == 0);
- SMB_ASSERT(node != NULL);
+ SMB_ASSERT(row != NULL);
+ node = talloc_get_type_abort(row, struct tree_node);
if (tree_node_has_children(node)) {
return "+";
}
@@ -370,9 +378,10 @@ static const char *tv_get_item_prefix(const void *row, unsigned col)
static const char *tv_get_item_label(const void *row, unsigned col)
{
- const struct tree_node *node = row;
+ const struct tree_node *node;
SMB_ASSERT(col == 0);
- SMB_ASSERT(node != NULL);
+ SMB_ASSERT(row != NULL);
+ node = talloc_get_type_abort(row, struct tree_node);
return node->name;
}
diff --git a/source3/utils/regedit_valuelist.c b/source3/utils/regedit_valuelist.c
index 4922cdb388..1c80c0911b 100644
--- a/source3/utils/regedit_valuelist.c
+++ b/source3/utils/regedit_valuelist.c
@@ -54,21 +54,26 @@ static const char *vl_get_column_header(const void *data, unsigned col)
static const void *vl_get_first_row(const void *data)
{
- const struct value_list *vl = data;
+ const struct value_list *vl;
- if (vl && vl->nvalues) {
- return &vl->values[0];
+ if (data) {
+ vl = talloc_get_type_abort(data, struct value_list);
+ if (vl->nvalues) {
+ return &vl->values[0];
+ }
}
+
return NULL;
}
static const void *vl_get_next_row(const void *data, const void *row)
{
- const struct value_list *vl = data;
+ const struct value_list *vl;
const struct value_item *value = row;
- SMB_ASSERT(vl != NULL);
+ SMB_ASSERT(data != NULL);
SMB_ASSERT(value != NULL);
+ vl = talloc_get_type_abort(data, struct value_list);
if (value == &vl->values[vl->nvalues - 1]) {
return NULL;
}
@@ -78,11 +83,12 @@ static const void *vl_get_next_row(const void *data, const void *row)
static const void *vl_get_prev_row(const void *data, const void *row)
{
- const struct value_list *vl = data;
+ const struct value_list *vl;
const struct value_item *value = row;
- SMB_ASSERT(vl != NULL);
+ SMB_ASSERT(data != NULL);
SMB_ASSERT(value != NULL);
+ vl = talloc_get_type_abort(data, struct value_list);
if (value == &vl->values[0]) {
return NULL;
}