summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--lib/struct.c7
-rw-r--r--lib/ubus.c5
-rw-r--r--main.c6
-rw-r--r--tests/cram/test_basic.t2
-rw-r--r--types.c2
-rw-r--r--vm.c2
6 files changed, 10 insertions, 14 deletions
diff --git a/lib/struct.c b/lib/struct.c
index 751127c..cf4499a 100644
--- a/lib/struct.c
+++ b/lib/struct.c
@@ -2012,7 +2012,7 @@ optimize_functions(void)
static formatstate_t *
parse_format(uc_vm_t *vm, uc_value_t *fmtval)
{
- ssize_t size, len, num, itemsize;
+ ssize_t size, num, itemsize;
const formatdef_t *e, *f;
const char *fmt, *s;
formatstate_t *state;
@@ -2040,7 +2040,6 @@ parse_format(uc_vm_t *vm, uc_value_t *fmtval)
s = fmt;
size = 0;
- len = 0;
ncodes = 0;
while ((c = *s++) != '\0') {
@@ -2080,7 +2079,6 @@ parse_format(uc_vm_t *vm, uc_value_t *fmtval)
case '*': /* fall through */
case 's':
case 'p':
- len++;
ncodes++;
break;
@@ -2088,8 +2086,6 @@ parse_format(uc_vm_t *vm, uc_value_t *fmtval)
break;
default:
- len += num;
-
if (num)
ncodes++;
@@ -2117,7 +2113,6 @@ parse_format(uc_vm_t *vm, uc_value_t *fmtval)
}
state = xalloc(sizeof(*state) + ncodes * sizeof(formatcode_t));
- state->len = len;
state->size = size;
state->ncodes = ncodes;
diff --git a/lib/ubus.c b/lib/ubus.c
index 085802b..b83e628 100644
--- a/lib/ubus.c
+++ b/lib/ubus.c
@@ -393,7 +393,7 @@ blob_to_ucv(uc_vm_t *vm, struct blob_attr *attr, bool table, const char **name)
return ucv_double_new(v.d);
case BLOBMSG_TYPE_STRING:
- return ucv_string_new(data);
+ return ucv_string_new_length(data, len - 1);
case BLOBMSG_TYPE_ARRAY:
return blob_array_to_ucv(vm, data, len, false);
@@ -444,7 +444,8 @@ ucv_to_blob(const char *name, uc_value_t *val, struct blob_buf *blob)
break;
case UC_STRING:
- blobmsg_add_string(blob, name, ucv_string_get(val));
+ blobmsg_add_field(blob, BLOBMSG_TYPE_STRING, name,
+ ucv_string_get(val), ucv_string_length(val) + 1);
break;
case UC_ARRAY:
diff --git a/main.c b/main.c
index 3957483..138447a 100644
--- a/main.c
+++ b/main.c
@@ -90,7 +90,7 @@ print_usage(const char *app)
" Preload the given `library`, optionally aliased to `name`.\n\n"
"-L pattern\n"
- " Append given `pattern` to default library search paths. If the pattern\n"
+ " Prepend given `pattern` to default library search paths. If the pattern\n"
" contains no `*`, it is added twice, once with `/*.so` and once with\n"
" `/*.uc` appended to it.\n\n"
@@ -505,8 +505,6 @@ main(int argc, char **argv)
.raw_mode = true
};
- uc_search_path_init(&config.module_search_path);
-
app = appname(argv[0]);
if (argc == 1) {
@@ -544,6 +542,8 @@ main(int argc, char **argv)
}
}
+ uc_search_path_init(&config.module_search_path);
+
optind = 1;
uc_vm_init(&vm, &config);
diff --git a/tests/cram/test_basic.t b/tests/cram/test_basic.t
index d7f78a3..798436e 100644
--- a/tests/cram/test_basic.t
+++ b/tests/cram/test_basic.t
@@ -61,7 +61,7 @@ check that ucode provides exepected help:
Preload the given `library`, optionally aliased to `name`.
-L pattern
- Append given `pattern` to default library search paths. If the pattern
+ Prepend given `pattern` to default library search paths. If the pattern
contains no `*`, it is added twice, once with `/*.so` and once with
`/*.uc` appended to it.
diff --git a/types.c b/types.c
index 321392e..7bb67a6 100644
--- a/types.c
+++ b/types.c
@@ -2222,6 +2222,8 @@ ucv_gc_common(uc_vm_t *vm, bool final)
uc_value_t *val;
size_t i;
+ vm->alloc_refs = 0;
+
/* back out early if value list is uninitialized */
if (!vm->values.prev || !vm->values.next)
return;
diff --git a/vm.c b/vm.c
index 5bc071b..8512f8c 100644
--- a/vm.c
+++ b/vm.c
@@ -2502,8 +2502,6 @@ uc_vm_gc_step(uc_vm_t *vm)
else {
ucv_gc(vm);
}
-
- vm->alloc_refs = 0;
}
}