mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Philipp Zabel <p.zabel@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 1/3] fs/parseopt: Add parseopt_llu_suffix
Date: Mon, 5 Feb 2018 08:26:36 +0100	[thread overview]
Message-ID: <20180205072636.pqq2achw4pmbpmip@pengutronix.de> (raw)
In-Reply-To: <20180201103717.17429-1-p.zabel@pengutronix.de>

On Thu, Feb 01, 2018 at 11:37:15AM +0100, Philipp Zabel wrote:
> Add an option parser using strtoull_suffix that can be used to
> parse a loop mount offset option.
> 
> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
> ---
>  include/parseopt.h |  2 ++
>  lib/parseopt.c     | 30 ++++++++++++++++++++++++++++++
>  2 files changed, 32 insertions(+)

Applied, thanks

Sascha

> 
> diff --git a/include/parseopt.h b/include/parseopt.h
> index 1f9763f8c9..273a371ac3 100644
> --- a/include/parseopt.h
> +++ b/include/parseopt.h
> @@ -1,5 +1,7 @@
>  #ifndef __PARSEOPT_H__
>  #define __PARSEOPT_H__
> +void parseopt_llu_suffix(const char *options, const char *opt,
> +			 unsigned long long *val);
>  
>  void parseopt_b(const char *options, const char *opt, bool *val);
>  void parseopt_hu(const char *options, const char *opt, unsigned short *val);
> diff --git a/lib/parseopt.c b/lib/parseopt.c
> index 8211733e3b..70983066d9 100644
> --- a/lib/parseopt.c
> +++ b/lib/parseopt.c
> @@ -122,3 +122,33 @@ again:
>  
>  	*val = xstrndup(parsed, endp - parsed);
>  }
> +
> +void parseopt_llu_suffix(const char *options, const char *opt,
> +			 unsigned long long *val)
> +{
> +	const char *start;
> +	size_t optlen = strlen(opt);
> +	unsigned long long v;
> +	char *endp;
> +
> +again:
> +	start = strstr(options, opt);
> +
> +	if (!start)
> +		return;
> +
> +	if (start > options && start[-1] != ',') {
> +		options = start;
> +		goto again;
> +	}
> +
> +	if (start[optlen] != '=') {
> +		options = start;
> +		goto again;
> +	}
> +
> +	v = strtoull_suffix(start + optlen + 1, &endp, 0);
> +
> +	if (*endp == ',' || *endp == '\0')
> +		*val = v;
> +}
> -- 
> 2.15.1
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      parent reply	other threads:[~2018-02-05  7:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-01 10:37 Philipp Zabel
2018-02-01 10:37 ` [PATCH 2/3] filetype: Add type detection at an offset Philipp Zabel
2018-02-01 10:37 ` [PATCH 3/3] fs: add support loop mount offset Philipp Zabel
2018-02-05  7:26 ` Sascha Hauer [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=20180205072636.pqq2achw4pmbpmip@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=p.zabel@pengutronix.de \
    /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