Re: [PATCH] util: string: Avoid use of deprecated function index()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Apr 23, 2015 at 10:48:06AM +0200, Peter Krempa wrote:
> ---
>  src/util/virstring.c | 17 ++++++++++++++++-
>  1 file changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/src/util/virstring.c b/src/util/virstring.c
> index 1cd4987..e48c29a 100644
> --- a/src/util/virstring.c
> +++ b/src/util/virstring.c
> @@ -976,6 +976,21 @@ static const char control_chars[] =
>      "\x10\x11\x12\x13\x14\x15\x16\x17"
>      "\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F";
> 
> +
> +static bool
> +virStringIsControlChar(char c)
> +{
> +    const char *cch;
> +
> +    for (cch = control_chars; *cch; cch++) {
> +        if (*cch == c)
> +            return true;
> +    }
> +
> +    return false;
> +}
> +
> +
>  bool
>  virStringHasControlChars(const char *str)
>  {
> @@ -1003,7 +1018,7 @@ virStringStripControlChars(char *str)
> 
>      len = strlen(str);
>      for (i = 0, j = 0; i < len; i++) {
> -        if (index(control_chars, str[i]))
> +        if (virStringIsControlChar(str[i]))

Why not simply   s/index/strchr/  which is the recommended POSIX
replacement ?


Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]