From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH] predef: simplify add_pre_buffer()
Date: Sun, 5 Jul 2020 12:29:10 +0200 [thread overview]
Message-ID: <20200705102910.12851-1-luc.vanoostenryck@gmail.com> (raw)
pre_buffer_begin & pre_buffer_end are the head and the tail of
a singly chained list. As such, it's slightly easier to not
keep a pointer on the last element but a pointer where the
next element should be written.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
lib.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/lib.c b/lib.c
index e56788260cb7..863900b54c3c 100644
--- a/lib.c
+++ b/lib.c
@@ -248,7 +248,7 @@ void die(const char *fmt, ...)
}
static struct token *pre_buffer_begin = NULL;
-static struct token *pre_buffer_end = NULL;
+static struct token **pre_buffer_next = &pre_buffer_begin;
int Waddress = 0;
int Waddress_space = 1;
@@ -348,11 +348,8 @@ void add_pre_buffer(const char *fmt, ...)
size = vsnprintf(buffer, sizeof(buffer), fmt, args);
va_end(args);
begin = tokenize_buffer(buffer, size, &end);
- if (!pre_buffer_begin)
- pre_buffer_begin = begin;
- if (pre_buffer_end)
- pre_buffer_end->next = begin;
- pre_buffer_end = end;
+ *pre_buffer_next = begin;
+ pre_buffer_next = &end->next;
}
////////////////////////////////////////////////////////////////////////////////
--
2.27.0
reply other threads:[~2020-07-05 10:29 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200705102910.12851-1-luc.vanoostenryck@gmail.com \
--to=luc.vanoostenryck@gmail.com \
--cc=linux-sparse@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).