This breaks the ABI so we merge this into the unreleased libndr-1.0.0.
The advantage of the new functions is there (except for print, which
is unchanged) is an error raised when the token is not found, so
we can be confident in the changes to the token behaviour.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13876
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Thu Dec 12 03:56:23 UTC 2019 on sn-devel-184
ndr_pull_set_switch_value: enum ndr_err_code (struct ndr_pull *, const void *, uint32_t)
ndr_pull_setup_relative_base_offset1: enum ndr_err_code (struct ndr_pull *, const void *, uint32_t)
ndr_pull_setup_relative_base_offset2: enum ndr_err_code (struct ndr_pull *, const void *)
-ndr_pull_steal_switch_value: uint32_t (struct ndr_pull *, const void *)
+ndr_pull_steal_switch_value: enum ndr_err_code (struct ndr_pull *, const void *, uint32_t *)
ndr_pull_string: enum ndr_err_code (struct ndr_pull *, int, const char **)
ndr_pull_string_array: enum ndr_err_code (struct ndr_pull *, int, const char ***)
ndr_pull_struct_blob: enum ndr_err_code (const DATA_BLOB *, TALLOC_CTX *, void *, ndr_pull_flags_fn_t)
ndr_push_setup_relative_base_offset2: enum ndr_err_code (struct ndr_push *, const void *)
ndr_push_short_relative_ptr1: enum ndr_err_code (struct ndr_push *, const void *)
ndr_push_short_relative_ptr2: enum ndr_err_code (struct ndr_push *, const void *)
-ndr_push_steal_switch_value: uint32_t (struct ndr_push *, const void *)
+ndr_push_steal_switch_value: enum ndr_err_code (struct ndr_push *, const void *, uint32_t *)
ndr_push_string: enum ndr_err_code (struct ndr_push *, int, const char *)
ndr_push_string_array: enum ndr_err_code (struct ndr_push *, int, const char **)
ndr_push_struct_blob: enum ndr_err_code (DATA_BLOB *, TALLOC_CTX *, const void *, ndr_push_flags_fn_t)
enum ndr_err_code ndr_push_set_switch_value(struct ndr_push *ndr, const void *p, uint32_t val);
enum ndr_err_code ndr_pull_set_switch_value(struct ndr_pull *ndr, const void *p, uint32_t val);
enum ndr_err_code ndr_print_set_switch_value(struct ndr_print *ndr, const void *p, uint32_t val);
-uint32_t ndr_push_steal_switch_value(struct ndr_push *ndr, const void *p);
+/* retrieve a switch value (for push) and remove it from the list */
+enum ndr_err_code ndr_push_steal_switch_value(struct ndr_push *ndr,
+ const void *p,
+ uint32_t *v);
+/* retrieve a switch value and remove it from the list */
uint32_t ndr_print_steal_switch_value(struct ndr_print *ndr, const void *p);
-uint32_t ndr_pull_steal_switch_value(struct ndr_pull *ndr, const void *p);
+/* retrieve a switch value and remove it from the list */
+enum ndr_err_code ndr_pull_steal_switch_value(struct ndr_pull *ndr,
+ const void *p,
+ uint32_t *v);
enum ndr_err_code ndr_pull_struct_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p, ndr_pull_flags_fn_t fn);
enum ndr_err_code ndr_pull_struct_blob_all(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p, ndr_pull_flags_fn_t fn);
enum ndr_err_code ndr_pull_struct_blob_all_noalloc(const DATA_BLOB *blob,
}
/* retrieve a switch value (for push) and remove it from the list */
-_PUBLIC_ uint32_t ndr_push_steal_switch_value(struct ndr_push *ndr, const void *p)
+_PUBLIC_ enum ndr_err_code ndr_push_steal_switch_value(struct ndr_push *ndr,
+ const void *p,
+ uint32_t *v)
{
- enum ndr_err_code status;
- uint32_t v;
-
- status = ndr_token_retrieve(&ndr->switch_list, p, &v);
- if (!NDR_ERR_CODE_IS_SUCCESS(status)) {
- return 0;
- }
-
- return v;
+ return ndr_token_retrieve(&ndr->switch_list, p, v);
}
/* retrieve a switch value and remove it from the list */
}
/* retrieve a switch value and remove it from the list */
-_PUBLIC_ uint32_t ndr_pull_steal_switch_value(struct ndr_pull *ndr, const void *p)
+_PUBLIC_ enum ndr_err_code ndr_pull_steal_switch_value(struct ndr_pull *ndr,
+ const void *p,
+ uint32_t *v)
{
- enum ndr_err_code status;
- uint32_t v;
-
- status = ndr_token_retrieve(&ndr->switch_list, p, &v);
- if (!NDR_ERR_CODE_IS_SUCCESS(status)) {
- return 0;
- }
-
- return v;
+ return ndr_token_retrieve(&ndr->switch_list, p, v);
}
/*
ndr->flags = ndr->flags & ~LIBNDR_FLAG_NDR64;
NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);
if (ndr_flags & NDR_SCALARS) {
- uint32_t level = ndr_push_steal_switch_value(ndr, r);
+ uint32_t level;
+ NDR_CHECK(ndr_push_steal_switch_value(ndr, r, &level));
NDR_CHECK(ndr_push_union_align(ndr, 4));
switch (level) {
case 24: {
ndr->flags = ndr->flags & ~LIBNDR_FLAG_NDR64;
NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);
if (ndr_flags & NDR_SCALARS) {
- uint32_t level = ndr_pull_steal_switch_value(ndr, r);
+ uint32_t level;
+ NDR_CHECK(ndr_pull_steal_switch_value(ndr, r, &level));
NDR_CHECK(ndr_pull_union_align(ndr, 4));
switch (level) {
case 24: {
$self->pidl("if (ndr_flags & NDR_SCALARS) {");
$self->indent;
$self->pidl("/* This token is not used again (except perhaps below in the NDR_BUFFERS case) */");
- $self->pidl("level = ndr_push_steal_switch_value($ndr, $varname);");
+ $self->pidl("NDR_CHECK(ndr_push_steal_switch_value($ndr, $varname, &level));");
$self->ParseUnionPushPrimitives($e, $ndr, $varname);
$self->deindent;
$self->pidl("if (!(ndr_flags & NDR_SCALARS)) {");
$self->indent;
$self->pidl("/* We didn't get it above, and the token is not needed after this. */");
- $self->pidl("level = ndr_push_steal_switch_value($ndr, $varname);");
+ $self->pidl("NDR_CHECK(ndr_push_steal_switch_value($ndr, $varname, &level));");
$self->deindent;
$self->pidl("}");
$self->ParseUnionPushDeferred($e, $ndr, $varname);
$self->pidl("if (ndr_flags & NDR_SCALARS) {");
$self->indent;
$self->pidl("/* This token is not used again (except perhaps below in the NDR_BUFFERS case) */");
- $self->pidl("level = ndr_pull_steal_switch_value($ndr, $varname);");
+ $self->pidl("NDR_CHECK(ndr_pull_steal_switch_value($ndr, $varname, &level));");
$self->ParseUnionPullPrimitives($e,$ndr,$varname,$switch_type);
$self->deindent;
$self->pidl("}");
$self->pidl("if (!(ndr_flags & NDR_SCALARS)) {");
$self->indent;
$self->pidl("/* We didn't get it above, and the token is not needed after this. */");
- $self->pidl("level = ndr_pull_steal_switch_value($ndr, $varname);");
+ $self->pidl("NDR_CHECK(ndr_pull_steal_switch_value($ndr, $varname, &level));");
$self->deindent;
$self->pidl("}");
$self->ParseUnionPullDeferred($e,$ndr,$varname);