Re: [PATCH] media: Fix misplaced parenthesis in strncmp use

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

 



On Wed, May 11, 2016 at 02:26:27PM +0200, Christophe Fergeau wrote:
> Due to a misplaced parenthesis, bootable media detection was doing
> strncmp(.., .., sizeof(..) != 0)
> instead of
> strncmp(.., .., sizeof(..)) != 0
> 
> This means we were comparing 1 character from BOOTABLE_TAG rather than
> the full string.
> ---
>  osinfo/osinfo_media.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/osinfo/osinfo_media.c b/osinfo/osinfo_media.c
> index d9fcba6..f7bf120 100644
> --- a/osinfo/osinfo_media.c
> +++ b/osinfo/osinfo_media.c
> @@ -713,7 +713,7 @@ static void on_svd_read(GObject *source,
>  
>      data->svd.system[MAX_SYSTEM - 1] = 0;
>  
> -    if (strncmp(BOOTABLE_TAG, data->svd.system, sizeof(BOOTABLE_TAG) != 0)) {
> +    if (strncmp(BOOTABLE_TAG, data->svd.system, sizeof(BOOTABLE_TAG)) != 0) {
>          g_set_error(&error,
>                      OSINFO_MEDIA_ERROR,
>                      OSINFO_MEDIA_ERROR_NOT_BOOTABLE,

ACK, this kind of thing is why we banned strncmp in libvirt :-) If anyone
is feeling motiviated, libosinfo shold be made to use g_str_equal() instead
and get 'make syntax-check' to block use of strcmp & friends to.


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 :|

_______________________________________________
Libosinfo mailing list
Libosinfo@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libosinfo



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

  Powered by Linux