On Wed, Mar 05, 2025 at 05:56:46PM -0800, Richard Henderson wrote:
> On 3/5/25 07:39, Philippe Mathieu-Daudé wrote:
> > +void legacy_binary_info_init(const char *argv0)
> > +{
> > +    g_auto(GStrv) tokens = g_strsplit(argv0, G_DIR_SEPARATOR_S, -1);
> > +    unsigned count = 0;
> > +    const char *binary_name;
> > +
> > +    while (tokens[count]) {
> > +        count++;
> > +    }
> > +    assert(count > 0);
> > +    binary_name = tokens[count - 1];
> 
> This is g_path_get_basename().
> 
> > +
> > +    for (size_t i = 0; i < ARRAY_SIZE(legacy_binary_infos); i++) {
> > +        if (!strcmp(legacy_binary_infos[i].binary_name, binary_name)) {
> > +            current_index = i;
> > +            return;
> > +        }
> > +    }
> > +    fprintf(stderr, "Missing legacy info for '%s' binary.\n", binary_name);
> > +    abort();
> > +}
> 
> I'm with Paolo that this should not abort here; Error is better.
> Even if the caller supplies error_fatal.
> 
> When testing for errors before and after a patch, I often rename
> the binary, e.g. qemu-system-aarch64-good / qemu-system-aarch64-bad.
> Leaving it in the same build directory is required in order to let
> it find the uninstalled rom images.
> 
> Is there a way we can preserve something akin to this?

Replacign !strcmp with  g_str_has_prefix in the above code would be
an simple option to preseve the use of custom suffixes, along with
special casing on existence of 'kvm' in the name.

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|


Reply via email to