Bug Summary

File:root/firefox-clang/dom/media/webrtc/transport/third_party/nrappkit/src/registry/c2ru.c
Warning:line 283, column 24
Although the value stored to 'r' is used in the enclosing expression, the value is never actually read from 'r'

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name Unified_c_nrappkit0.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -analyzer-config-compatibility-mode=true -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -relaxed-aliasing -ffp-contract=off -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/root/firefox-clang/obj-x86_64-pc-linux-gnu/dom/media/webrtc/transport/third_party/nrappkit/nrappkit_nrappkit -fcoverage-compilation-dir=/root/firefox-clang/obj-x86_64-pc-linux-gnu/dom/media/webrtc/transport/third_party/nrappkit/nrappkit_nrappkit -resource-dir /usr/lib/llvm-21/lib/clang/21 -include /root/firefox-clang/config/gcc_hidden.h -include /root/firefox-clang/obj-x86_64-pc-linux-gnu/mozilla-config.h -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/system_wrappers -U _FORTIFY_SOURCE -D _FORTIFY_SOURCE=2 -D _GLIBCXX_ASSERTIONS -D DEBUG=1 -D _FILE_OFFSET_BITS=64 -D CHROMIUM_BUILD -D USE_LIBJPEG_TURBO=1 -D USE_NSS=1 -D ENABLE_ONE_CLICK_SIGNIN -D GTK_DISABLE_SINGLE_INCLUDES=1 -D _ISOC99_SOURCE=1 -D ENABLE_REMOTING=1 -D ENABLE_WEBRTC=1 -D ENABLE_CONFIGURATION_POLICY -D ENABLE_INPUT_SPEECH -D ENABLE_NOTIFICATIONS -D ENABLE_GPU=1 -D ENABLE_EGLIMAGE=1 -D USE_SKIA=1 -D ENABLE_TASK_MANAGER=1 -D ENABLE_WEB_INTENTS=1 -D ENABLE_EXTENSIONS=1 -D ENABLE_PLUGIN_INSTALLATION=1 -D ENABLE_PROTECTOR_SERVICE=1 -D ENABLE_SESSION_SERVICE=1 -D ENABLE_THEMES=1 -D ENABLE_BACKGROUND=1 -D ENABLE_AUTOMATION=1 -D ENABLE_PRINTING=1 -D ENABLE_CAPTIVE_PORTAL_DETECTION=1 -D SANITY_CHECKS -D R_PLATFORM_INT_TYPES=<stdint.h> -D R_DEFINED_INT2=int16_t -D R_DEFINED_UINT2=uint16_t -D R_DEFINED_INT4=int32_t -D R_DEFINED_UINT4=uint32_t -D R_DEFINED_INT8=int64_t -D R_DEFINED_UINT8=uint64_t -D LINUX -D HAVE_LIBM=1 -D HAVE_STRDUP=1 -D HAVE_STRLCPY=1 -D HAVE_SYS_TIME_H=1 -D HAVE_VFPRINTF=1 -D NEW_STDIORETSIGTYPE=void -D TIME_WITH_SYS_TIME_H=1 -D NO_REG_RPC=1 -D __UNUSED__=__attribute__((unused)) -D DYNAMIC_ANNOTATIONS_ENABLED=1 -D WTF_USE_DYNAMIC_ANNOTATIONS=1 -D _DEBUG -D MOZ_HAS_MOZGLUE -D MOZILLA_INTERNAL_API -D IMPL_LIBXUL -D MOZ_SUPPORT_LEAKCHECKING -D STATIC_EXPORTABLE_JS_API -I /root/firefox-clang/dom/media/webrtc/transport/third_party/nrappkit -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dom/media/webrtc/transport/third_party/nrappkit/nrappkit_nrappkit -I /root/firefox-clang/dom/media/webrtc/transport/third_party/nrappkit/src/event -I /root/firefox-clang/dom/media/webrtc/transport/third_party/nrappkit/src/log -I /root/firefox-clang/dom/media/webrtc/transport/third_party/nrappkit/src/port/generic/include -I /root/firefox-clang/dom/media/webrtc/transport/third_party/nrappkit/src/registry -I /root/firefox-clang/dom/media/webrtc/transport/third_party/nrappkit/src/share -I /root/firefox-clang/dom/media/webrtc/transport/third_party/nrappkit/src/stats -I /root/firefox-clang/dom/media/webrtc/transport/third_party/nrappkit/src/util -I /root/firefox-clang/dom/media/webrtc/transport/third_party/nrappkit/src/util/libekr -I /root/firefox-clang/dom/media/webrtc/transport/third_party/nrappkit/src/port/linux/include -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/ipc/ipdl/_ipdlheaders -I /root/firefox-clang/ipc/chromium/src -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/include -D MOZILLA_CLIENT -internal-isystem /usr/lib/llvm-21/lib/clang/21/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-error=tautological-type-limit-compare -Wno-range-loop-analysis -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wno-error=free-nonheap-object -Wno-error=atomic-alignment -Wno-error=deprecated-builtins -Wno-psabi -Wno-error=builtin-macro-redefined -Wno-unknown-warning-option -Wno-parentheses -Wno-strict-prototypes -Wno-format -Wno-format-security -ferror-limit 19 -fstrict-flex-arrays=1 -stack-protector 2 -fstack-clash-protection -ftrivial-auto-var-init=pattern -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -vectorize-loops -vectorize-slp -analyzer-checker optin.performance.Padding -analyzer-output=html -analyzer-config stable-report-filename=true -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/scan-build-2025-06-27-100320-3286336-1 -x c Unified_c_nrappkit0.c
1/*
2 *
3 * c2ru.c
4 *
5 * $Source: /Users/ekr/tmp/nrappkit-dump/nrappkit/src/registry/c2ru.c,v $
6 * $Revision: 1.3 $
7 * $Date: 2007/06/26 22:37:50 $
8 *
9 * c2r utility methods
10 *
11 *
12 * Copyright (C) 2005, Network Resonance, Inc.
13 * Copyright (C) 2006, Network Resonance, Inc.
14 * All Rights Reserved
15 *
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
18 * are met:
19 *
20 * 1. Redistributions of source code must retain the above copyright
21 * notice, this list of conditions and the following disclaimer.
22 * 2. Redistributions in binary form must reproduce the above copyright
23 * notice, this list of conditions and the following disclaimer in the
24 * documentation and/or other materials provided with the distribution.
25 * 3. Neither the name of Network Resonance, Inc. nor the name of any
26 * contributors to this software may be used to endorse or promote
27 * products derived from this software without specific prior written
28 * permission.
29 *
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
31 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
34 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
35 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
36 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
37 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
38 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
39 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
40 * POSSIBILITY OF SUCH DAMAGE.
41 *
42 *
43 */
44
45#include <sys/queue.h>
46#include <string.h>
47#include <registry.h>
48#include "nr_common.h"
49#include <r_errors.h>
50#include <r_macros.h>
51#include <ctype.h>
52#include "c2ru.h"
53
54
55#define NRGET(func, type, get)int func(NR_registry parent, char *child, type **out) { int r
, _status; NR_registry registry; type tmp; if ((r = nr_c2ru_make_registry
(parent, child, registry))) do { int _r=r; if(!_r) _r=-1; ; _status
=_r; goto abort;} while(0); if ((r = get(registry, &tmp))
) { if (r != 2) do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto
abort;} while(0); *out = 0; } else { *out = r_calloc(0,1,sizeof
(tmp)); if (*out == 0) do { int _r=1; if(!_r) _r=-1; ; _status
=_r; goto abort;} while(0); **out = tmp; } _status = 0; abort
: return (_status); }
\
56int \
57func(NR_registry parent, char *child, type **out) \
58{ \
59 int r, _status; \
60 NR_registry registry; \
61 type tmp; \
62 \
63 if ((r = nr_c2ru_make_registry(parent, child, registry))) \
64 ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while
(0)
; \
65 \
66 if ((r = get(registry, &tmp))) { \
67 if (r != R_NOT_FOUND2) \
68 ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while
(0)
; \
69 *out = 0; \
70 } \
71 else { \
72 *out = RCALLOC(sizeof(tmp))r_calloc(0,1,sizeof(tmp)); \
73 if (*out == 0) \
74 ABORT(R_NO_MEMORY)do { int _r=1; if(!_r) _r=-1; ; _status=_r; goto abort;} while
(0)
; \
75 **out = tmp; \
76 } \
77 \
78 _status = 0; \
79abort: \
80 return (_status); \
81}
82
83int
84nr_c2ru_get_char(NR_registry parent, char *child, char **out)
85{
86 int r, _status;
87 NR_registry registry;
88 char tmp;
89
90 if ((r = nr_c2ru_make_registry(parent, child, registry)))
91 ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while
(0)
;
92
93 if ((r = NR_reg_get_char(registry, &tmp))) {
94 if (r != R_NOT_FOUND2)
95 ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while
(0)
;
96 *out = 0;
97 }
98 else {
99 *out = RCALLOC(sizeof(tmp))r_calloc(0,1,sizeof(tmp));
100 if (*out == 0)
101 ABORT(R_NO_MEMORY)do { int _r=1; if(!_r) _r=-1; ; _status=_r; goto abort;} while
(0)
;
102 **out = tmp;
103 }
104
105 _status = 0;
106abort:
107 return (_status);
108}
109NRGET(nr_c2ru_get_uchar, UCHAR, NR_reg_get_uchar)int nr_c2ru_get_uchar(NR_registry parent, char *child, UCHAR *
*out) { int r, _status; NR_registry registry; UCHAR tmp; if (
(r = nr_c2ru_make_registry(parent, child, registry))) do { int
_r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while(0); if
((r = NR_reg_get_uchar(registry, &tmp))) { if (r != 2) do
{ int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while(
0); *out = 0; } else { *out = r_calloc(0,1,sizeof(tmp)); if (
*out == 0) do { int _r=1; if(!_r) _r=-1; ; _status=_r; goto abort
;} while(0); **out = tmp; } _status = 0; abort: return (_status
); }
110NRGET(nr_c2ru_get_int2, INT2, NR_reg_get_int2)int nr_c2ru_get_int2(NR_registry parent, char *child, INT2 **
out) { int r, _status; NR_registry registry; INT2 tmp; if ((r
= nr_c2ru_make_registry(parent, child, registry))) do { int _r
=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while(0); if ((
r = NR_reg_get_int2(registry, &tmp))) { if (r != 2) do { int
_r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while(0); *out
= 0; } else { *out = r_calloc(0,1,sizeof(tmp)); if (*out == 0
) do { int _r=1; if(!_r) _r=-1; ; _status=_r; goto abort;} while
(0); **out = tmp; } _status = 0; abort: return (_status); }
111NRGET(nr_c2ru_get_uint2, UINT2, NR_reg_get_uint2)int nr_c2ru_get_uint2(NR_registry parent, char *child, UINT2 *
*out) { int r, _status; NR_registry registry; UINT2 tmp; if (
(r = nr_c2ru_make_registry(parent, child, registry))) do { int
_r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while(0); if
((r = NR_reg_get_uint2(registry, &tmp))) { if (r != 2) do
{ int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while(
0); *out = 0; } else { *out = r_calloc(0,1,sizeof(tmp)); if (
*out == 0) do { int _r=1; if(!_r) _r=-1; ; _status=_r; goto abort
;} while(0); **out = tmp; } _status = 0; abort: return (_status
); }
112NRGET(nr_c2ru_get_int4, INT4, NR_reg_get_int4)int nr_c2ru_get_int4(NR_registry parent, char *child, INT4 **
out) { int r, _status; NR_registry registry; INT4 tmp; if ((r
= nr_c2ru_make_registry(parent, child, registry))) do { int _r
=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while(0); if ((
r = NR_reg_get_int4(registry, &tmp))) { if (r != 2) do { int
_r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while(0); *out
= 0; } else { *out = r_calloc(0,1,sizeof(tmp)); if (*out == 0
) do { int _r=1; if(!_r) _r=-1; ; _status=_r; goto abort;} while
(0); **out = tmp; } _status = 0; abort: return (_status); }
113NRGET(nr_c2ru_get_uint4, UINT4, NR_reg_get_uint4)int nr_c2ru_get_uint4(NR_registry parent, char *child, UINT4 *
*out) { int r, _status; NR_registry registry; UINT4 tmp; if (
(r = nr_c2ru_make_registry(parent, child, registry))) do { int
_r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while(0); if
((r = NR_reg_get_uint4(registry, &tmp))) { if (r != 2) do
{ int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while(
0); *out = 0; } else { *out = r_calloc(0,1,sizeof(tmp)); if (
*out == 0) do { int _r=1; if(!_r) _r=-1; ; _status=_r; goto abort
;} while(0); **out = tmp; } _status = 0; abort: return (_status
); }
114NRGET(nr_c2ru_get_int8, INT8, NR_reg_get_int8)int nr_c2ru_get_int8(NR_registry parent, char *child, INT8 **
out) { int r, _status; NR_registry registry; INT8 tmp; if ((r
= nr_c2ru_make_registry(parent, child, registry))) do { int _r
=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while(0); if ((
r = NR_reg_get_int8(registry, &tmp))) { if (r != 2) do { int
_r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while(0); *out
= 0; } else { *out = r_calloc(0,1,sizeof(tmp)); if (*out == 0
) do { int _r=1; if(!_r) _r=-1; ; _status=_r; goto abort;} while
(0); **out = tmp; } _status = 0; abort: return (_status); }
115NRGET(nr_c2ru_get_uint8, UINT8, NR_reg_get_uint8)int nr_c2ru_get_uint8(NR_registry parent, char *child, UINT8 *
*out) { int r, _status; NR_registry registry; UINT8 tmp; if (
(r = nr_c2ru_make_registry(parent, child, registry))) do { int
_r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while(0); if
((r = NR_reg_get_uint8(registry, &tmp))) { if (r != 2) do
{ int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while(
0); *out = 0; } else { *out = r_calloc(0,1,sizeof(tmp)); if (
*out == 0) do { int _r=1; if(!_r) _r=-1; ; _status=_r; goto abort
;} while(0); **out = tmp; } _status = 0; abort: return (_status
); }
116NRGET(nr_c2ru_get_double, double, NR_reg_get_double)int nr_c2ru_get_double(NR_registry parent, char *child, double
**out) { int r, _status; NR_registry registry; double tmp; if
((r = nr_c2ru_make_registry(parent, child, registry))) do { int
_r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while(0); if
((r = NR_reg_get_double(registry, &tmp))) { if (r != 2) do
{ int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while(
0); *out = 0; } else { *out = r_calloc(0,1,sizeof(tmp)); if (
*out == 0) do { int _r=1; if(!_r) _r=-1; ; _status=_r; goto abort
;} while(0); **out = tmp; } _status = 0; abort: return (_status
); }
117NRGET(nr_c2ru_get_string, char*, NR_reg_alloc_string)int nr_c2ru_get_string(NR_registry parent, char *child, char*
**out) { int r, _status; NR_registry registry; char* tmp; if
((r = nr_c2ru_make_registry(parent, child, registry))) do { int
_r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while(0); if
((r = NR_reg_alloc_string(registry, &tmp))) { if (r != 2
) do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while
(0); *out = 0; } else { *out = r_calloc(0,1,sizeof(tmp)); if (
*out == 0) do { int _r=1; if(!_r) _r=-1; ; _status=_r; goto abort
;} while(0); **out = tmp; } _status = 0; abort: return (_status
); }
118NRGET(nr_c2ru_get_data, Data, NR_reg_alloc_data)int nr_c2ru_get_data(NR_registry parent, char *child, Data **
out) { int r, _status; NR_registry registry; Data tmp; if ((r
= nr_c2ru_make_registry(parent, child, registry))) do { int _r
=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while(0); if ((
r = NR_reg_alloc_data(registry, &tmp))) { if (r != 2) do {
int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while(0)
; *out = 0; } else { *out = r_calloc(0,1,sizeof(tmp)); if (*out
== 0) do { int _r=1; if(!_r) _r=-1; ; _status=_r; goto abort
;} while(0); **out = tmp; } _status = 0; abort: return (_status
); }
119
120
121#define NRSET(func, type, set)int func(NR_registry parent, char *child, type *in) { int r, _status
; NR_registry registry; if (in == 0) return 0; if ((r = nr_c2ru_make_registry
(parent, child, registry))) do { int _r=r; if(!_r) _r=-1; ; _status
=_r; goto abort;} while(0); if ((r = set(registry, *in))) do {
int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while(0)
; _status = 0; abort: return (_status); }
\
122int \
123func(NR_registry parent, char *child, type *in) \
124{ \
125 int r, _status; \
126 NR_registry registry; \
127 \
128 if (in == 0) \
129 return 0; \
130 \
131 if ((r = nr_c2ru_make_registry(parent, child, registry))) \
132 ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while
(0)
; \
133 \
134 if ((r = set(registry, *in))) \
135 ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while
(0)
; \
136 \
137 _status = 0; \
138abort: \
139 return (_status); \
140}
141
142NRSET(nr_c2ru_set_char, char, NR_reg_set_char)int nr_c2ru_set_char(NR_registry parent, char *child, char *in
) { int r, _status; NR_registry registry; if (in == 0) return
0; if ((r = nr_c2ru_make_registry(parent, child, registry)))
do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while
(0); if ((r = NR_reg_set_char(registry, *in))) do { int _r=r;
if(!_r) _r=-1; ; _status=_r; goto abort;} while(0); _status =
0; abort: return (_status); }
143NRSET(nr_c2ru_set_uchar, UCHAR, NR_reg_set_uchar)int nr_c2ru_set_uchar(NR_registry parent, char *child, UCHAR *
in) { int r, _status; NR_registry registry; if (in == 0) return
0; if ((r = nr_c2ru_make_registry(parent, child, registry)))
do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while
(0); if ((r = NR_reg_set_uchar(registry, *in))) do { int _r=r
; if(!_r) _r=-1; ; _status=_r; goto abort;} while(0); _status
= 0; abort: return (_status); }
144NRSET(nr_c2ru_set_int2, INT2, NR_reg_set_int2)int nr_c2ru_set_int2(NR_registry parent, char *child, INT2 *in
) { int r, _status; NR_registry registry; if (in == 0) return
0; if ((r = nr_c2ru_make_registry(parent, child, registry)))
do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while
(0); if ((r = NR_reg_set_int2(registry, *in))) do { int _r=r;
if(!_r) _r=-1; ; _status=_r; goto abort;} while(0); _status =
0; abort: return (_status); }
145NRSET(nr_c2ru_set_uint2, UINT2, NR_reg_set_uint2)int nr_c2ru_set_uint2(NR_registry parent, char *child, UINT2 *
in) { int r, _status; NR_registry registry; if (in == 0) return
0; if ((r = nr_c2ru_make_registry(parent, child, registry)))
do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while
(0); if ((r = NR_reg_set_uint2(registry, *in))) do { int _r=r
; if(!_r) _r=-1; ; _status=_r; goto abort;} while(0); _status
= 0; abort: return (_status); }
146NRSET(nr_c2ru_set_int4, INT4, NR_reg_set_int4)int nr_c2ru_set_int4(NR_registry parent, char *child, INT4 *in
) { int r, _status; NR_registry registry; if (in == 0) return
0; if ((r = nr_c2ru_make_registry(parent, child, registry)))
do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while
(0); if ((r = NR_reg_set_int4(registry, *in))) do { int _r=r;
if(!_r) _r=-1; ; _status=_r; goto abort;} while(0); _status =
0; abort: return (_status); }
147NRSET(nr_c2ru_set_uint4, UINT4, NR_reg_set_uint4)int nr_c2ru_set_uint4(NR_registry parent, char *child, UINT4 *
in) { int r, _status; NR_registry registry; if (in == 0) return
0; if ((r = nr_c2ru_make_registry(parent, child, registry)))
do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while
(0); if ((r = NR_reg_set_uint4(registry, *in))) do { int _r=r
; if(!_r) _r=-1; ; _status=_r; goto abort;} while(0); _status
= 0; abort: return (_status); }
148NRSET(nr_c2ru_set_int8, INT8, NR_reg_set_int8)int nr_c2ru_set_int8(NR_registry parent, char *child, INT8 *in
) { int r, _status; NR_registry registry; if (in == 0) return
0; if ((r = nr_c2ru_make_registry(parent, child, registry)))
do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while
(0); if ((r = NR_reg_set_int8(registry, *in))) do { int _r=r;
if(!_r) _r=-1; ; _status=_r; goto abort;} while(0); _status =
0; abort: return (_status); }
149NRSET(nr_c2ru_set_uint8, UINT8, NR_reg_set_uint8)int nr_c2ru_set_uint8(NR_registry parent, char *child, UINT8 *
in) { int r, _status; NR_registry registry; if (in == 0) return
0; if ((r = nr_c2ru_make_registry(parent, child, registry)))
do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while
(0); if ((r = NR_reg_set_uint8(registry, *in))) do { int _r=r
; if(!_r) _r=-1; ; _status=_r; goto abort;} while(0); _status
= 0; abort: return (_status); }
150NRSET(nr_c2ru_set_double, double, NR_reg_set_double)int nr_c2ru_set_double(NR_registry parent, char *child, double
*in) { int r, _status; NR_registry registry; if (in == 0) return
0; if ((r = nr_c2ru_make_registry(parent, child, registry)))
do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while
(0); if ((r = NR_reg_set_double(registry, *in))) do { int _r=
r; if(!_r) _r=-1; ; _status=_r; goto abort;} while(0); _status
= 0; abort: return (_status); }
151NRSET(nr_c2ru_set_string, char*, NR_reg_set_string)int nr_c2ru_set_string(NR_registry parent, char *child, char*
*in) { int r, _status; NR_registry registry; if (in == 0) return
0; if ((r = nr_c2ru_make_registry(parent, child, registry)))
do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while
(0); if ((r = NR_reg_set_string(registry, *in))) do { int _r=
r; if(!_r) _r=-1; ; _status=_r; goto abort;} while(0); _status
= 0; abort: return (_status); }
152
153int
154nr_c2ru_set_data(NR_registry parent, char *child, Data *in)
155{
156 int r, _status;
157 NR_registry registry;
158
159 if (in == 0)
160 return 0;
161
162 if ((r = nr_c2ru_make_registry(parent, child, registry)))
163 ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while
(0)
;
164
165 if ((r = NR_reg_set_bytes(registry, in->data, in->len)))
166 ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while
(0)
;
167
168 _status = 0;
169abort:
170 return (_status);
171}
172
173#define NRFREE(func, type)int func(type *in) { if (in) if(in) r_free(in); return 0; } \
174int \
175func(type *in) \
176{ \
177 if (in) \
178 RFREE(in)if(in) r_free(in); \
179 return 0; \
180}
181
182NRFREE(nr_c2ru_free_char, char)int nr_c2ru_free_char(char *in) { if (in) if(in) r_free(in); return
0; }
183NRFREE(nr_c2ru_free_uchar, UCHAR)int nr_c2ru_free_uchar(UCHAR *in) { if (in) if(in) r_free(in)
; return 0; }
184NRFREE(nr_c2ru_free_int2, INT2)int nr_c2ru_free_int2(INT2 *in) { if (in) if(in) r_free(in); return
0; }
185NRFREE(nr_c2ru_free_uint2, UINT2)int nr_c2ru_free_uint2(UINT2 *in) { if (in) if(in) r_free(in)
; return 0; }
186NRFREE(nr_c2ru_free_int4, INT4)int nr_c2ru_free_int4(INT4 *in) { if (in) if(in) r_free(in); return
0; }
187NRFREE(nr_c2ru_free_uint4, UINT4)int nr_c2ru_free_uint4(UINT4 *in) { if (in) if(in) r_free(in)
; return 0; }
188NRFREE(nr_c2ru_free_int8, INT8)int nr_c2ru_free_int8(INT8 *in) { if (in) if(in) r_free(in); return
0; }
189NRFREE(nr_c2ru_free_uint8, UINT8)int nr_c2ru_free_uint8(UINT8 *in) { if (in) if(in) r_free(in)
; return 0; }
190NRFREE(nr_c2ru_free_double, double)int nr_c2ru_free_double(double *in) { if (in) if(in) r_free(in
); return 0; }
191
192
193int
194nr_c2ru_free_string(char **in)
195{
196 if (*in)
197 RFREE(*in)if(*in) r_free(*in);
198 if (in)
199 RFREE(in)if(in) r_free(in);
200 return 0;
201}
202
203int
204nr_c2ru_free_data(Data *in)
205{
206 int r, _status;
207
208 if (in) {
209 if ((r=r_data_destroy(&in)))
210 ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while
(0)
;
211 }
212
213 _status = 0;
214abort:
215 return (_status);
216}
217
218int
219nr_c2ru_get_children(NR_registry parent, char *child, void *ptr, size_t size, int (*get)(NR_registry, void*))
220{
221 int r, _status;
222 NR_registry registry;
223 unsigned int count;
224 unsigned int i;
225 NR_registry name;
226 struct entry { TAILQ_ENTRY(entry)struct { struct entry *tqe_next; struct entry **tqe_prev; } entries; } *entry;
227 TAILQ_HEAD(, entry)struct { struct entry *tqh_first; struct entry **tqh_last; } *tailq = (void*)ptr;
228
229 TAILQ_INIT(tailq)do { (((tailq))->tqh_first) = ((void*)0); (tailq)->tqh_last
= &(((tailq))->tqh_first); ; } while (0)
;
230
231 if ((r=nr_c2ru_make_registry(parent, child, registry)))
232 ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while
(0)
;
233
234 if ((r=NR_reg_get_child_count(registry, &count))) {
235 if (r != R_NOT_FOUND2)
236 ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while
(0)
;
237 }
238 else {
239 for (i = 0; i < count; ++i) {
240 if ((r=NR_reg_get_child_registry(registry, i, name))) {
241 /* ignore R_NOT_FOUND errors */
242 if (r == R_NOT_FOUND2)
243 continue;
244 else
245 ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while
(0)
;
246 }
247
248 if ((r=get(name, &entry))) {
249 /* ignore R_NOT_FOUND errors */
250 if (r == R_NOT_FOUND2)
251 continue;
252 else
253 ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while
(0)
;
254 }
255
256 TAILQ_INSERT_TAIL(tailq, entry, entries)do { (((entry))->entries.tqe_next) = ((void*)0); (entry)->
entries.tqe_prev = (tailq)->tqh_last; *(tailq)->tqh_last
= (entry); (tailq)->tqh_last = &(((entry))->entries
.tqe_next); ; ; } while (0)
;
257 }
258 }
259
260 _status = 0;
261abort:
262 return (_status);
263}
264
265int
266nr_c2ru_set_children(NR_registry parent, char *child, void *ptr, int (*set)(NR_registry, void*), int (*label)(NR_registry, void*, char[NR_REG_MAX_NR_REGISTRY_LEN128]))
267{
268 int r, _status;
269 NR_registry registry;
270 int i;
271 NR_registry name;
272 char buffer[NR_REG_MAX_NR_REGISTRY_LEN128];
273 struct entry { TAILQ_ENTRY(entry)struct { struct entry *tqe_next; struct entry **tqe_prev; } entries; } *entry;
274 TAILQ_HEAD(, entry)struct { struct entry *tqh_first; struct entry **tqh_last; } *tailq = (void*)ptr;
275
276 if ((r=nr_c2ru_make_registry(parent, child, registry)))
277 ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while
(0)
;
278
279 (void)NR_reg_del(registry);
280
281 i = 0;
282 TAILQ_FOREACH(entry, tailq, entries)for ((entry) = (((tailq))->tqh_first); (entry); (entry) = (
((entry))->entries.tqe_next))
{
283 if (label == 0 || (r=label(registry, entry, buffer))) {
Although the value stored to 'r' is used in the enclosing expression, the value is never actually read from 'r'
284 snprintf(buffer, sizeof(buffer), "%d", i);
285 }
286 if ((r=nr_c2ru_make_registry(registry, buffer, name)))
287 ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while
(0)
;
288
289 if ((r=set(name, entry)))
290 ABORT(r)do { int _r=r; if(!_r) _r=-1; ; _status=_r; goto abort;} while
(0)
;
291
292 ++i;
293 }
294
295 _status = 0;
296abort:
297 return (_status);
298}
299
300int
301nr_c2ru_free_children(void *ptr, int (*free)(void*))
302{
303 struct entry { TAILQ_ENTRY(entry)struct { struct entry *tqe_next; struct entry **tqe_prev; } entries; } *entry;
304 TAILQ_HEAD(, entry)struct { struct entry *tqh_first; struct entry **tqh_last; } *tailq = (void*)ptr;
305
306 while (! TAILQ_EMPTY(tailq)((tailq)->tqh_first == ((void*)0))) {
307 entry = TAILQ_FIRST(tailq)((tailq)->tqh_first);
308 TAILQ_REMOVE(tailq, entry, entries)do { if (((((entry))->entries.tqe_next)) != ((void*)0)) ((
(entry))->entries.tqe_next)->entries.tqe_prev = (entry)
->entries.tqe_prev; else { (tailq)->tqh_last = (entry)->
entries.tqe_prev; ; } *(entry)->entries.tqe_prev = (((entry
))->entries.tqe_next); ; ; ; } while (0)
;
309 (void)free(entry);
310 }
311
312 return 0;
313}
314
315/* requires parent already in legal form */
316int
317nr_c2ru_make_registry(NR_registry parent, char *child, NR_registry out)
318{
319 return NR_reg_make_registry(parent, child, out);
320}