Преглед на файлове

Using bsd-stryle LISTs.

Michele Orrù преди 11 години
родител
ревизия
ab1189323d
променени са 2 файла, в които са добавени 5 реда и са изтрити 8 реда
  1. 2 1
      src/qa.c
  2. 3 7
      src/questions/allquestions.c

+ 2 - 1
src/qa.c

@@ -4,6 +4,7 @@
 #include <stdint.h>
 #include <string.h>
 #include <unistd.h>
+#include <bsd/sys/queue.h>
 
 #include <openssl/err.h>
 #include <openssl/pem.h>
@@ -80,7 +81,7 @@ void qa_dispose(X509 *crt)
   rsa = X509_get_pubkey(crt)->pkey.rsa;
 
   printf("[+] Certificate acquired\n");
-  for (q=questions.lh_first; q; q = q->qs.le_next) {
+  LIST_FOREACH(q, &questions, qs) {
     printf( "[-] Running: %s\n", q->pretty_name);
     if (q->setup)    q->setup();
     if (q->test)     q->test(crt);

+ 3 - 7
src/questions/allquestions.c

@@ -1,6 +1,6 @@
 #include <assert.h>
 #include <string.h>
-#include <sys/queue.h>
+#include <bsd/sys/queue.h>
 
 #include "qa/questions/questions.h"
 
@@ -10,16 +10,12 @@
  */
 void select_question(const char *sq)
 {
-  qa_question_t *q;
+  qa_question_t *q, *tmpq;
 
   select_all_questions();
   assert(questions.lh_first);
 
-  for (q = questions.lh_first; q && strcmp(q->name, sq); q = questions.lh_first)
-    LIST_REMOVE(q, qs);
-  if (!q) return;
-
-  for (q = q->qs.le_next; q; q = q->qs.le_next)
+  LIST_FOREACH_SAFE(q, &questions, qs, tmpq)
     if (strcmp(q->name, sq))
       LIST_REMOVE(q, qs);
 }