From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH 15/15] cleanup: move hexval() to utils.c
Date: Sun, 5 Jul 2020 15:02:20 +0200 [thread overview]
Message-ID: <20200705130220.26230-16-luc.vanoostenryck@gmail.com> (raw)
In-Reply-To: <20200705130220.26230-1-luc.vanoostenryck@gmail.com>
Now lib.c contains almost nothing else than library entrypoints.
Move a small utility, hexval(), to utils.c to complete this cleanup.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
lib.c | 17 -----------------
lib.h | 2 --
utils.c | 17 +++++++++++++++++
utils.h | 4 ++++
4 files changed, 21 insertions(+), 19 deletions(-)
diff --git a/lib.c b/lib.c
index f512be2e1a43..57c89a16448e 100644
--- a/lib.c
+++ b/lib.c
@@ -50,23 +50,6 @@
#include "bits.h"
-unsigned int hexval(unsigned int c)
-{
- int retval = 256;
- switch (c) {
- case '0'...'9':
- retval = c - '0';
- break;
- case 'a'...'f':
- retval = c - 'a' + 10;
- break;
- case 'A'...'F':
- retval = c - 'A' + 10;
- break;
- }
- return retval;
-}
-
static void do_warn(const char *type, struct position pos, const char * fmt, va_list args)
{
static char buffer[512];
diff --git a/lib.h b/lib.h
index 81253a3e7ee5..46483f2bed5c 100644
--- a/lib.h
+++ b/lib.h
@@ -45,8 +45,6 @@
#endif
-extern unsigned int hexval(unsigned int c);
-
struct position {
unsigned int type:6,
stream:14,
diff --git a/utils.c b/utils.c
index 094df3f9bf1c..72fff00ff91b 100644
--- a/utils.c
+++ b/utils.c
@@ -8,6 +8,23 @@
#include <stdio.h>
+unsigned int hexval(unsigned int c)
+{
+ int retval = 256;
+ switch (c) {
+ case '0'...'9':
+ retval = c - '0';
+ break;
+ case 'a'...'f':
+ retval = c - 'a' + 10;
+ break;
+ case 'A'...'F':
+ retval = c - 'A' + 10;
+ break;
+ }
+ return retval;
+}
+
void *xmemdup(const void *src, size_t len)
{
return memcpy(__alloc_bytes(len), src, len);
diff --git a/utils.h b/utils.h
index 7bd14f467799..079fb02a3e94 100644
--- a/utils.h
+++ b/utils.h
@@ -8,6 +8,10 @@
#include <stddef.h>
#include <stdarg.h>
+///
+// return the value coresponding to an hexadecimal digit
+unsigned int hexval(unsigned int c);
+
///
// duplicate a memory buffer in a newly allocated buffer.
// @src: a pointer to the memory buffer to be duplicated
--
2.27.0
prev parent reply other threads:[~2020-07-05 13:02 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-05 13:02 [PATCH 00/15] tidy-up options / reorganize lib.c Luc Van Oostenryck
2020-07-05 13:02 ` [PATCH 01/15] options: let handle_onoff_switch() use null terminated arrays Luc Van Oostenryck
2020-07-05 13:02 ` [PATCH 02/15] options: move -Wsparse-all's processing out of handle_onoff_switch() Luc Van Oostenryck
2020-07-05 13:02 ` Luc Van Oostenryck
2020-07-05 13:02 ` [PATCH 03/15] options: move on top the definition of warning type enums Luc Van Oostenryck
2020-07-05 13:02 ` Luc Van Oostenryck
2020-07-05 13:02 ` [PATCH 04/15] options: make Wsparse_error less special Luc Van Oostenryck
2020-07-05 13:02 ` [PATCH 05/15] options: handle_onoff_switch() can handle any flags, not only warnings Luc Van Oostenryck
2020-07-05 13:02 ` [PATCH 06/15] options: move helpers up Luc Van Oostenryck
2020-07-05 13:02 ` Luc Van Oostenryck
2020-07-05 13:02 ` [PATCH 07/15] options: alphasort the handle_switch_[a-zA_Z]() Luc Van Oostenryck
2020-07-05 13:02 ` Luc Van Oostenryck
2020-07-05 13:02 ` [PATCH 08/15] options: avoid spaces between function name and arguments list Luc Van Oostenryck
2020-07-05 13:02 ` [PATCH 09/15] options: move declaration of tabstop out of "token.h" Luc Van Oostenryck
2020-07-05 13:02 ` [PATCH 10/15] options: add a small helper: handle_switch_finalize() Luc Van Oostenryck
2020-07-05 13:02 ` [PATCH 11/15] options: move option parsing in a separate file Luc Van Oostenryck
2020-07-05 13:02 ` [PATCH 12/15] options: keep the options sorted Luc Van Oostenryck
2020-07-05 13:02 ` Luc Van Oostenryck
2020-07-05 13:02 ` [PATCH 13/15] cleanup: move predefines in a separate file Luc Van Oostenryck
2020-07-05 13:02 ` [PATCH 14/15] cleanup: move parsing helpers to parse.c Luc Van Oostenryck
2020-07-05 17:27 ` Linus Torvalds
2020-07-05 20:45 ` Luc Van Oostenryck
2020-07-05 13:02 ` Luc Van Oostenryck [this message]
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=20200705130220.26230-16-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).