On Sun, Sep 03, 2023 at 04:23:23PM +0100, Richard W.M. Jones wrote: > Copy the human_size() function from common/utils/ into the new > human-size.h header in common/include/. Remove human-size.c and > combine the tests into one. > --- > common/include/human-size.h | 51 ++++++++++++++++++
This file was created by inheriting nbdkit's weaker BSD licensing... > common/include/test-human-size.c | 79 +++++++++++++++++++++++++--- > common/utils/Makefile.am | 10 +--- > common/utils/human-size.c | 56 -------------------- > common/utils/human-size.h | 49 ------------------ ...while this file was originally created with libnbd's LGPLv2+ licensing. By merging LGPLv2+ code into a file containing only a BSD license header, you have created an ambiguity on what license should be assumed when using human_size(). Could you explicitly clarify that the relaxing of the license was intentional, so that it is safe to then merge libnbd's code into nbdkit without dragging in LGPLv2+ code? > +static inline char * > +human_size (char *buf, uint64_t bytes, bool *human) > +{ > + static const char ext[][2] = { "E", "P", "T", "G", "M", "K", "" }; > + size_t i; Code motion, so this is pre-existing, but this seems rather lengthy, compared to a more compact: static const char ext[] = "EPTGMK"; > + > + if (buf == NULL) { > + buf = malloc (HUMAN_SIZE_LONGEST); > + if (buf == NULL) > + return NULL; > + } > + > + /* Work out which extension to use, if any. */ > + i = 6; > + if (bytes != 0) { > + while ((bytes & 1023) == 0) { > + bytes >>= 10; > + i--; > + } > + } > + > + /* Set the flag to true if we're going to add a human-readable extension. > */ > + if (human) > + *human = ext[i][0] != '\0'; *human = ext[i] != '\0'; > + > + snprintf (buf, HUMAN_SIZE_LONGEST, "%" PRIu64 "%s", bytes, ext[i]); snprintf (buf, HUMAN_SIZE_LONGEST, "%" PRIu64 ".1s", bytes, &ext[i]); > + return buf; > +} > + -- Eric Blake, Principal Software Engineer Red Hat, Inc. Virtualization: qemu.org | libguestfs.org _______________________________________________ Libguestfs mailing list Libguestfs@redhat.com https://listman.redhat.com/mailman/listinfo/libguestfs