With the type canary, it's unnecessary. Though the implementation is
a bit more awkward since they longer map directly through to list_top/tail.
{
struct failtest_call *i;
{
struct failtest_call *i;
- while ((i = tlist_top(&history, struct failtest_call, list)) != NULL)
+ while ((i = tlist_top(&history, list)) != NULL)
free_call(i);
failtable_clear(&failtable);
free_call(i);
failtable_clear(&failtable);
char *failpath;
struct failtest_call *c;
char *failpath;
struct failtest_call *c;
- c = tlist_tail(&history, struct failtest_call, list);
+ c = tlist_tail(&history, list);
diff = time_sub(time_now(), start);
failpath = failpath_string();
p = strrchr(c->file, '/');
diff = time_sub(time_now(), start);
failpath = failpath_string();
p = strrchr(c->file, '/');
free(failpath);
}
/* From here on, we have to clean up! */
free(failpath);
}
/* From here on, we have to clean up! */
- our_history_start = tlist_tail(&history, struct failtest_call,
- list);
+ our_history_start = tlist_tail(&history, list);
close(control[0]);
close(output[0]);
/* Don't swallow stderr if we're tracing. */
close(control[0]);
close(output[0]);
/* Don't swallow stderr if we're tracing. */
* static enum failtest_result dont_fail_alloc(struct tlist_calls *history)
* {
* struct failtest_call *call;
* static enum failtest_result dont_fail_alloc(struct tlist_calls *history)
* {
* struct failtest_call *call;
- * call = tlist_tail(history, struct failtest_call, list);
+ * call = tlist_tail(history, list);
* if (call->type == FAILTEST_MALLOC
* || call->type == FAILTEST_CALLOC
* || call->type == FAILTEST_REALLOC)
* if (call->type == FAILTEST_MALLOC
* || call->type == FAILTEST_CALLOC
* || call->type == FAILTEST_REALLOC)
{
struct lbalance_task *task;
{
struct lbalance_task *task;
- while ((task = tlist_top(&lb->tasks, struct lbalance_task, list))) {
+ while ((task = tlist_top(&lb->tasks, list))) {
assert(task->lb == lb);
tlist_del_from(&lb->tasks, task, list);
lb->num_tasks--;
assert(task->lb == lb);
tlist_del_from(&lb->tasks, task, list);
lb->num_tasks--;
{
const struct failtest_call *last;
{
const struct failtest_call *last;
- last = tlist_tail(history, struct failtest_call, list);
+ last = tlist_tail(history, list);
if (failtest_suppress)
return FAIL_DONT_FAIL;
if (failtest_suppress)
return FAIL_DONT_FAIL;
{
struct tlist_children children;
struct child child = { "child" };
{
struct tlist_children children;
struct child child = { "child" };
+#ifdef FAIL
+ struct cousin *c;
+#else
+ struct child *c;
+#endif
tlist_init(&children);
tlist_add(&children, &child, list);
tlist_init(&children);
tlist_add(&children, &child, list);
- c = tlist_tail(&children,
-#ifdef FAIL
-#if !HAVE_FLEXIBLE_ARRAY_MEMBER
-#error Need flexible array members to check type
-#endif
- struct cousin,
-#else
- struct child,
-#endif
- list);
+ c = tlist_tail(&children, list);
(void) c; /* Suppress unused-but-set-variable warning. */
return 0;
}
(void) c; /* Suppress unused-but-set-variable warning. */
return 0;
}
{
struct tlist_children children;
struct child child = { "child" };
{
struct tlist_children children;
struct child child = { "child" };
+#ifdef FAIL
+ struct cousin *c;
+#else
+ struct child *c;
+#endif
tlist_init(&children);
tlist_add(&children, &child, list);
tlist_init(&children);
tlist_add(&children, &child, list);
- c = tlist_top(&children,
-#ifdef FAIL
-#if !HAVE_FLEXIBLE_ARRAY_MEMBER
-#error Need flexible array members to check type
-#endif
- struct cousin,
-#else
- struct child,
-#endif
- list);
+ c = tlist_top(&children, list);
(void) c; /* Suppress unused-but-set-variable warning. */
return 0;
}
(void) c; /* Suppress unused-but-set-variable warning. */
return 0;
}
ok1(tlist_check(&parent.children, NULL));
/* Test tlist_top */
ok1(tlist_check(&parent.children, NULL));
/* Test tlist_top */
- ok1(tlist_top(&parent.children, struct child, list) == &c1);
+ ok1(tlist_top(&parent.children, list) == &c1);
- ok1(tlist_tail(&parent.children, struct child, list) == &c3);
+ ok1(tlist_tail(&parent.children, list) == &c3);
/* Test tlist_for_each. */
i = 0;
/* Test tlist_for_each. */
i = 0;
ok1(tlist_empty(&parent.children));
/* Test list_top/list_tail on empty list. */
ok1(tlist_empty(&parent.children));
/* Test list_top/list_tail on empty list. */
- ok1(tlist_top(&parent.children, struct child, list) == NULL);
- ok1(tlist_tail(&parent.children, struct child, list) == NULL);
+ ok1(tlist_top(&parent.children, list) == (struct child *)NULL);
+ ok1(tlist_tail(&parent.children, list) == (struct child *)NULL);
/**
* tlist_top - get the first entry in a list
* @h: the tlist
/**
* tlist_top - get the first entry in a list
* @h: the tlist
- * @type: the type of the entry
* @member: the list_node member of the type
*
* If the list is empty, returns NULL.
*
* Example:
* struct child *first;
* @member: the list_node member of the type
*
* If the list is empty, returns NULL.
*
* Example:
* struct child *first;
- * first = tlist_top(&parent->children, struct child, list);
+ * first = tlist_top(&parent->children, list);
-#define tlist_top(h, type, member) \
- list_top(tlist_raw((h), (type *)NULL), type, member)
+#define tlist_top(h, member) \
+ ((tcon_type((h), canary)) \
+ list_top_(&(h)->raw, \
+ (char *)(&(h)->_tcon[0].canary->member) - \
+ (char *)((h)->_tcon[0].canary)))
/**
* tlist_tail - get the last entry in a list
* @h: the tlist
/**
* tlist_tail - get the last entry in a list
* @h: the tlist
- * @type: the type of the entry
* @member: the list_node member of the type
*
* If the list is empty, returns NULL.
*
* Example:
* struct child *last;
* @member: the list_node member of the type
*
* If the list is empty, returns NULL.
*
* Example:
* struct child *last;
- * last = tlist_tail(&parent->children, struct child, list);
+ * last = tlist_tail(&parent->children, list);
-#define tlist_tail(h, type, member) \
- list_tail(tlist_raw((h), (type *)NULL), type, member)
+#define tlist_tail(h, member) \
+ ((tcon_type((h), canary)) \
+ list_tail_(&(h)->raw, \
+ (char *)(&(h)->_tcon[0].canary->member) - \
+ (char *)((h)->_tcon[0].canary)))
/**
* tlist_for_each - iterate through a list.
/**
* tlist_for_each - iterate through a list.
while (num_running < lbalance_target(lb)) {
int p[2];
while (num_running < lbalance_target(lb)) {
int p[2];
- c = tlist_top(&pending, struct command, list);
+ c = tlist_top(&pending, list);
struct command *c;
const void *ctx;
struct command *c;
const void *ctx;
- while ((c = tlist_top(&done, struct command, list)) == NULL) {
+ while ((c = tlist_top(&done, list)) == NULL) {
if (tlist_empty(&pending) && tlist_empty(&running))
return NULL;
reap_output();
if (tlist_empty(&pending) && tlist_empty(&running))
return NULL;
reap_output();