commit: 770b756d6ee4e984e0b62b4f02a105131fbf5a1f
parent 991c95f4d95555a815f5434fbe350303519f5c3e
Author: Michael Forney <mforney@mforney.org>
Date: Mon, 24 Jun 2019 22:51:01 -0700
util-linux: Some more portability fixes
Diffstat:
5 files changed, 191 insertions(+), 1 deletion(-)
diff --git a/pkg/util-linux/patch/0007-Avoid-initialization-of-flexible-array-in-struct.patch b/pkg/util-linux/patch/0007-Avoid-initialization-of-flexible-array-in-struct.patch
@@ -0,0 +1,97 @@
+From 8dac421210d9f0b49ac39287ace471a45faab352 Mon Sep 17 00:00:00 2001
+From: Michael Forney <mforney@mforney.org>
+Date: Mon, 24 Jun 2019 22:48:57 -0700
+Subject: [PATCH] Avoid initialization of flexible array in struct
+
+---
+ disk-utils/fdisk-menu.c | 18 +++++++++---------
+ 1 file changed, 9 insertions(+), 9 deletions(-)
+
+diff --git a/disk-utils/fdisk-menu.c b/disk-utils/fdisk-menu.c
+index cd104e20b..58abb16a6 100644
+--- a/disk-utils/fdisk-menu.c
++++ b/disk-utils/fdisk-menu.c
+@@ -37,7 +37,7 @@ struct menu {
+ const struct menu *,
+ const struct menu_entry *);
+
+- struct menu_entry entries[]; /* NULL terminated array */
++ struct menu_entry *entries; /* NULL terminated array */
+ };
+
+ struct menu_context {
+@@ -93,7 +93,7 @@ DECLARE_MENU_CB(generic_menu_cb);
+ /* Generic menu */
+ static const struct menu menu_generic = {
+ .callback = generic_menu_cb,
+- .entries = {
++ .entries = (struct menu_entry[]){
+ MENU_BSEP(N_("Generic")),
+ MENU_ENT ('d', N_("delete a partition")),
+ MENU_ENT ('F', N_("list free unpartitioned space")),
+@@ -133,7 +133,7 @@ static const struct menu menu_createlabel = {
+ .callback = createlabel_menu_cb,
+ .exclude = FDISK_DISKLABEL_BSD,
+ .nonested = 1,
+- .entries = {
++ .entries = (struct menu_entry[]){
+ MENU_SEP(N_("Create a new label")),
+ MENU_ENT('g', N_("create a new empty GPT partition table")),
+ MENU_ENT('G', N_("create a new empty SGI (IRIX) partition table")),
+@@ -150,7 +150,7 @@ static const struct menu menu_createlabel = {
+ static const struct menu menu_geo = {
+ .callback = geo_menu_cb,
+ .exclude = FDISK_DISKLABEL_GPT | FDISK_DISKLABEL_BSD,
+- .entries = {
++ .entries = (struct menu_entry[]){
+ MENU_XSEP(N_("Geometry (for the current label)")),
+ MENU_XENT('c', N_("change number of cylinders")),
+ MENU_XENT('h', N_("change number of heads")),
+@@ -162,7 +162,7 @@ static const struct menu menu_geo = {
+ static const struct menu menu_gpt = {
+ .callback = gpt_menu_cb,
+ .label = FDISK_DISKLABEL_GPT,
+- .entries = {
++ .entries = (struct menu_entry[]){
+ MENU_BSEP(N_("GPT")),
+ MENU_XENT('i', N_("change disk GUID")),
+ MENU_XENT('n', N_("change partition name")),
+@@ -183,7 +183,7 @@ static const struct menu menu_gpt = {
+ static const struct menu menu_sun = {
+ .callback = sun_menu_cb,
+ .label = FDISK_DISKLABEL_SUN,
+- .entries = {
++ .entries = (struct menu_entry[]){
+ MENU_BSEP(N_("Sun")),
+ MENU_ENT('a', N_("toggle the read-only flag")),
+ MENU_ENT('c', N_("toggle the mountable flag")),
+@@ -200,7 +200,7 @@ static const struct menu menu_sun = {
+ static const struct menu menu_sgi = {
+ .callback = sgi_menu_cb,
+ .label = FDISK_DISKLABEL_SGI,
+- .entries = {
++ .entries = (struct menu_entry[]){
+ MENU_SEP(N_("SGI")),
+ MENU_ENT('a', N_("select bootable partition")),
+ MENU_ENT('b', N_("edit bootfile entry")),
+@@ -213,7 +213,7 @@ static const struct menu menu_sgi = {
+ static const struct menu menu_dos = {
+ .callback = dos_menu_cb,
+ .label = FDISK_DISKLABEL_DOS,
+- .entries = {
++ .entries = (struct menu_entry[]){
+ MENU_BSEP(N_("DOS (MBR)")),
+ MENU_ENT('a', N_("toggle a bootable flag")),
+ MENU_ENT('b', N_("edit nested BSD disklabel")),
+@@ -231,7 +231,7 @@ static const struct menu menu_dos = {
+ static const struct menu menu_bsd = {
+ .callback = bsd_menu_cb,
+ .label = FDISK_DISKLABEL_BSD,
+- .entries = {
++ .entries = (struct menu_entry[]){
+ MENU_SEP(N_("BSD")),
+ MENU_ENT('e', N_("edit drive data")),
+ MENU_ENT('i', N_("install bootstrap")),
+--
+2.22.0
+
diff --git a/pkg/util-linux/patch/0008-Use-MAXIMUM_PARTS-instead-of-VLA.patch b/pkg/util-linux/patch/0008-Use-MAXIMUM_PARTS-instead-of-VLA.patch
@@ -0,0 +1,28 @@
+From b0a9d92b358b22ef7759f16aca681a7b99935f22 Mon Sep 17 00:00:00 2001
+From: Michael Forney <mforney@mforney.org>
+Date: Mon, 24 Jun 2019 23:41:53 -0700
+Subject: [PATCH] Use MAXIMUM_PARTS instead of VLA
+
+This is the upper bound on the pte array, so just use it as the
+static array length.
+---
+ libfdisk/src/dos.c | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+diff --git a/libfdisk/src/dos.c b/libfdisk/src/dos.c
+index 2543edc04..1ba95c34a 100644
+--- a/libfdisk/src/dos.c
++++ b/libfdisk/src/dos.c
+@@ -1543,8 +1543,7 @@ static int dos_verify_disklabel(struct fdisk_context *cxt)
+ {
+ size_t i, j;
+ fdisk_sector_t total = 1, n_sectors = cxt->total_sectors;
+- fdisk_sector_t first[cxt->label->nparts_max],
+- last[cxt->label->nparts_max];
++ fdisk_sector_t first[MAXIMUM_PARTS], last[MAXIMUM_PARTS];
+ struct dos_partition *p;
+ struct fdisk_dos_label *l = self_label(cxt);
+
+--
+2.22.0
+
diff --git a/pkg/util-linux/patch/0009-Use-alloca-if-VLAs-aren-t-supported.patch b/pkg/util-linux/patch/0009-Use-alloca-if-VLAs-aren-t-supported.patch
@@ -0,0 +1,28 @@
+From 7e547e0c1525165a860872503a5b461278ab2299 Mon Sep 17 00:00:00 2001
+From: Michael Forney <mforney@mforney.org>
+Date: Mon, 24 Jun 2019 23:54:21 -0700
+Subject: [PATCH] Use alloca if VLAs aren't supported
+
+---
+ lib/path.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/lib/path.c b/lib/path.c
+index f7fd19592..ecbd59e14 100644
+--- a/lib/path.c
++++ b/lib/path.c
+@@ -927,7 +927,11 @@ static int ul_path_cpuparse(struct path_cxt *pc, cpu_set_t **set, int maxcpus, i
+ {
+ FILE *f;
+ size_t setsize, len = maxcpus * 7;
++#ifndef __STDC_NO_VLA__
+ char buf[len];
++#else
++ char *buf = alloca(len);
++#endif
+ int rc;
+
+ *set = NULL;
+--
+2.22.0
+
diff --git a/pkg/util-linux/patch/0010-Use-static-inline-function-for-cmp_numbers.patch b/pkg/util-linux/patch/0010-Use-static-inline-function-for-cmp_numbers.patch
@@ -0,0 +1,37 @@
+From 324b036444402fd2f008c1bfe979ea4281827313 Mon Sep 17 00:00:00 2001
+From: Michael Forney <mforney@mforney.org>
+Date: Tue, 25 Jun 2019 00:13:43 -0700
+Subject: [PATCH] Use static inline function for cmp_numbers
+
+All callers use it with an unsigned type, so just specialize for
+uintmax_t.
+---
+ include/c.h | 12 +++++-------
+ 1 file changed, 5 insertions(+), 7 deletions(-)
+
+diff --git a/include/c.h b/include/c.h
+index 0b96ff1c0..9787ec341 100644
+--- a/include/c.h
++++ b/include/c.h
+@@ -136,13 +136,11 @@ umin(uintmax_t x, uintmax_t y)
+ return x < y ? x : y;
+ }
+
+-#ifndef cmp_numbers
+-# define cmp_numbers(x, y) __extension__ ({ \
+- __typeof__(x) _a = (x); \
+- __typeof__(y) _b = (y); \
+- (void) (&_a == &_b); \
+- _a == _b ? 0 : _a > _b ? 1 : -1; })
+-#endif
++static inline uintmax_t
++cmp_numbers(uintmax_t x, uintmax_t y)
++{
++ return x == y ? 0 : x > y ? 1 : -1;
++}
+
+ #ifndef offsetof
+ #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
+--
+2.22.0
+
diff --git a/pkg/util-linux/ver b/pkg/util-linux/ver
@@ -1 +1 @@
-2.34 r1
+2.34 r2