Re: [PATCH 06/12] db: Use volume-size info for detection

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

 



On Sun, Mar 15, 2015 at 04:04:53PM +0000, Zeeshan Ali (Khattak) wrote:
> If volume-size is known of a media, ensure that its the same as media

it's

> being compared with, for detection. This will enable us to differentiate
> ISOs with exactly same volume-id, system-id and application-id.
> 
> Its possible that we encounter two different ISOs that have the same

It's

> volume-size, not just the other IDs but chances of that happening are
> extremely small. Even if that happens, this patch doesn't make things
> worse for that scenerio.

scenario

> ---
>  osinfo/osinfo_db.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/osinfo/osinfo_db.c b/osinfo/osinfo_db.c
> index 241ee47..c7730c8 100644
> --- a/osinfo/osinfo_db.c
> +++ b/osinfo/osinfo_db.c
> @@ -548,6 +548,7 @@ osinfo_db_guess_os_from_media_internal(OsinfoDb *db,
>      const gchar *media_system;
>      const gchar *media_publisher;
>      const gchar *media_application;
> +    gint64 media_vol_size;
>  
>      g_return_val_if_fail(OSINFO_IS_DB(db), NULL);
>      g_return_val_if_fail(media != NULL, NULL);
> @@ -556,6 +557,7 @@ osinfo_db_guess_os_from_media_internal(OsinfoDb *db,
>      media_system = osinfo_media_get_system_id(media);
>      media_publisher = osinfo_media_get_publisher_id(media);
>      media_application = osinfo_media_get_application_id(media);
> +    media_vol_size = osinfo_media_get_volume_size(media);
>  
>      oss = osinfo_list_get_elements(OSINFO_LIST(db->priv->oses));
>      for (os_iter = oss; os_iter; os_iter = os_iter->next) {
> @@ -572,11 +574,14 @@ osinfo_db_guess_os_from_media_internal(OsinfoDb *db,
>              const gchar *os_system = osinfo_media_get_system_id(os_media);
>              const gchar *os_publisher = osinfo_media_get_publisher_id(os_media);
>              const gchar *os_application = osinfo_media_get_application_id(os_media);
> +            gint64 os_vol_size = osinfo_media_get_volume_size(os_media);
>  
>              if (match_regex(os_volume, media_volume) &&
>                  match_regex(os_application, media_application) &&
>                  match_regex(os_system, media_system) &&
> -                match_regex(os_publisher, media_publisher)) {
> +                match_regex(os_publisher, media_publisher) &&
> +                (os_vol_size <= 0 ||
> +                 os_vol_size == media_vol_size)) {

Doesn't this fit on a single line?
Alternatively, you could move the <= 0 check out of this already
complicated check:
if (os_vol_size <= 0)
    os_vol_size = media_vol_size;

and then only have the simpler (os_vol_size == media_vol_size) check


Christophe

Attachment: pgpSX5PoLmO8s.pgp
Description: PGP signature

_______________________________________________
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