Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F178155796
D62139.1796140227.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
D62139.1796140227.diff
View Options
diff --git a/sys/kern/subr_unit.c b/sys/kern/subr_unit.c
--- a/sys/kern/subr_unit.c
+++ b/sys/kern/subr_unit.c
@@ -288,6 +288,11 @@
}
for (;;) {
+ if (up == NULL) {
+ iter->ipos = -1;
+ iter->upos = uh;
+ return;
+ }
if (y + 1 < iter->upos_first_item + up->len) {
if (up->ptr == uh) {
iter->ipos = y + 1;
@@ -306,11 +311,6 @@
iter->upos_first_item += up->len;
y = iter->upos_first_item - 1;
up = iter->upos = TAILQ_NEXT((struct unr *)iter->upos, list);
- if (iter->upos == NULL) {
- iter->ipos = -1;
- iter->upos = uh;
- return;
- }
}
}
@@ -1261,10 +1261,50 @@
exit(res);
}
+static void
+test_iter_trivial(void)
+{
+ struct unrhdr *uh;
+ void *ihandle;
+ uh = new_unrhdr(TBASE, INT_MAX, NULL);
+ int i, v, x, res;
+
+ res = 0;
+ for (i = 0; i < XSIZE; i++) {
+ x = alloc_unr(uh);
+ if (x != i + TBASE) {
+ VPRINTF("alloc_unr_specific failed %d %d\n", x,
+ i + TBASE);
+ res = 1;
+ }
+ }
+ ihandle = create_iter_unr(uh);
+ i = 0;
+ while ((v = next_iter_unr(ihandle)) != -1) {
+ x = i + TBASE;
+ if (x != v) {
+ VPRINTF("iter %d: iter %d != %d\n", i, v, x);
+ if (res == 0) {
+ if (verbose)
+ print_unrhdr(uh);
+ res = 1;
+ }
+ } else {
+ VPRINTF("iter %d: val %d\n", i, v);
+ }
+ i++;
+ }
+ free_iter_unr(ihandle);
+ clean_unrhdr(uh);
+ clear_unrhdr(uh);
+ delete_unrhdr(uh);
+ exit(res);
+}
+
static void
usage(char **argv)
{
- printf("%s [-h] [-i] [-r REPETITIONS] [-v]\n", argv[0]);
+ printf("%s [-h] [-i|-I] [-r REPETITIONS] [-v]\n", argv[0]);
}
int
@@ -1276,16 +1316,20 @@
long reps = 1, m;
int ch;
u_int i;
- bool testing_iter;
+ bool testing_iter, testing_iter_trivial;
verbose = false;
testing_iter = false;
+ testing_iter_trivial = false;
- while ((ch = getopt(argc, argv, "hir:v")) != -1) {
+ while ((ch = getopt(argc, argv, "hiIr:v")) != -1) {
switch (ch) {
case 'i':
testing_iter = true;
break;
+ case 'I':
+ testing_iter_trivial = true;
+ break;
case 'r':
errno = 0;
reps = strtol(optarg, NULL, 0);
@@ -1310,6 +1354,9 @@
if (testing_iter)
test_iter();
+ if (testing_iter_trivial)
+ test_iter_trivial();
+
uh = new_unrhdr(0, count - 1, NULL);
print_unrhdr(uh);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 1, 3:50 PM (23 h, 45 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
42068528
Default Alt Text
D62139.1796140227.diff (2 KB)
Attached To
Mode
D62139: unr(9): fix iterator with trivial unit allocations
Attached
Detach File
Event Timeline