From: Dave Wysochanski <dwysocha@redhat.com>
To: lvm-devel@redhat.com
Subject: [PATCH REPOST] convert _count_hyphens to generalised count_chars and export
Date: Fri, 20 Apr 2007 13:17:43 -0400 [thread overview]
Message-ID: <1177089463.11574.0.camel@linux-cxyg> (raw)
In-Reply-To: <1177081612.4206.11.camel@linux-cxyg>
Yet another version (similar) of this patch is coming so don't bother
review at this point.
On Fri, 2007-04-20 at 11:06 -0400, Dave Wysochanski wrote:
> (NOTE: only change from previous patch - remove '_' from '_count_chars')
> Should not change functional behavior and be simple to review.
> Adds newly created function to lvm-string.h exports.
>
>
> Index: LVM2/lib/misc/lvm-string.c
> ===================================================================
> --- LVM2.orig/lib/misc/lvm-string.c 2007-04-20 10:31:14.000000000 -0400
> +++ LVM2/lib/misc/lvm-string.c 2007-04-20 11:00:53.000000000 -0400
> @@ -36,21 +36,6 @@ int emit_to_buffer(char **buffer, size_t
> }
>
> /*
> - * Device layer names are all of the form <vg>-<lv>-<layer>, any
> - * other hyphens that appear in these names are quoted with yet
> - * another hyphen. The top layer of any device has no layer
> - * name. eg, vg0-lvol0.
> - */
> -static void _count_hyphens(const char *str, size_t *len, int *hyphens)
> -{
> - const char *ptr;
> -
> - for (ptr = str; *ptr; ptr++, (*len)++)
> - if (*ptr == '-')
> - (*hyphens)++;
> -}
> -
> -/*
> * Copies a string, quoting hyphens with hyphens.
> */
> static void _quote_hyphens(char **out, const char *src)
> @@ -63,6 +48,17 @@ static void _quote_hyphens(char **out, c
> }
> }
>
> +
> +void count_chars(const char *str, size_t *len, int *count,
> + char c)
> +{
> + const char *ptr;
> +
> + for (ptr = str; *ptr; ptr++, (*len)++)
> + if (*ptr == c)
> + (*count)++;
> +}
> +
> /*
> * <vg>-<lv>-<layer> or if !layer just <vg>-<lv>.
> */
> @@ -73,11 +69,11 @@ char *build_dm_name(struct dm_pool *mem,
> int hyphens = 1;
> char *r, *out;
>
> - _count_hyphens(vgname, &len, &hyphens);
> - _count_hyphens(lvname, &len, &hyphens);
> + count_chars(vgname, &len, &hyphens, '-');
> + count_chars(lvname, &len, &hyphens, '-');
>
> if (layer && *layer) {
> - _count_hyphens(layer, &len, &hyphens);
> + count_chars(layer, &len, &hyphens, '-');
> hyphens++;
> }
>
> @@ -105,6 +101,12 @@ char *build_dm_name(struct dm_pool *mem,
> return r;
> }
>
> +/*
> + * Device layer names are all of the form <vg>-<lv>-<layer>, any
> + * other hyphens that appear in these names are quoted with yet
> + * another hyphen. The top layer of any device has no layer
> + * name. eg, vg0-lvol0.
> + */
> int validate_name(const char *n)
> {
> register char c;
> Index: LVM2/lib/misc/lvm-string.h
> ===================================================================
> --- LVM2.orig/lib/misc/lvm-string.h 2007-04-20 10:31:14.000000000 -0400
> +++ LVM2/lib/misc/lvm-string.h 2007-04-20 11:01:06.000000000 -0400
> @@ -30,4 +30,7 @@ char *build_dm_name(struct dm_pool *mem,
>
> int validate_name(const char *n);
>
> +void count_chars(const char *str, size_t *len, int *count,
> + char c);
> +
> #endif
> Index: LVM2/WHATS_NEW
> ===================================================================
> --- LVM2.orig/WHATS_NEW 2007-04-20 10:31:14.000000000 -0400
> +++ LVM2/WHATS_NEW 2007-04-20 11:05:29.000000000 -0400
> @@ -1,5 +1,6 @@
> Version 2.02.25 -
> =================================
> + Convert _count_hyphens to generalized count_chars.
> Add dev_read_circular.
> Add pvck command stub.
> Update lists of attribute characters in man pages.
>
>
> --
> lvm-devel mailing list
> lvm-devel at redhat.com
> https://www.redhat.com/mailman/listinfo/lvm-devel
next prev parent reply other threads:[~2007-04-20 17:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-20 14:37 [PATCH] convert _count_hyphens to generalised _count_chars and export Dave Wysochanski
2007-04-20 15:06 ` [PATCH REPOST] convert _count_hyphens to generalised count_chars " Dave Wysochanski
2007-04-20 17:17 ` Dave Wysochanski [this message]
2007-04-23 18:57 ` [PATCH REPOST2] convert _count_hyphens to generalised count_chars_null " Dave Wysochanski
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=1177089463.11574.0.camel@linux-cxyg \
--to=dwysocha@redhat.com \
--cc=lvm-devel@redhat.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.