diff options
| author | Michael Forney <mforney@mforney.org> | 2019-05-31 01:01:08 -0700 |
|---|---|---|
| committer | Michael Forney <mforney@mforney.org> | 2019-05-31 01:07:55 -0700 |
| commit | d3f95465ec2fd1080a1e0a17f24c75b7ef1bce5f (patch) | |
| tree | f808f79f8bb4673f6f5c472a3c67039d5ec65c47 /pkg/kbd/patch/0001-Avoid-pointer-arithmetic-on-void.patch | |
| parent | fb607204770832bf53d1df09dd723b1167fc185e (diff) | |
kbd: Fix a few portability issues
Diffstat (limited to 'pkg/kbd/patch/0001-Avoid-pointer-arithmetic-on-void.patch')
| -rw-r--r-- | pkg/kbd/patch/0001-Avoid-pointer-arithmetic-on-void.patch | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/pkg/kbd/patch/0001-Avoid-pointer-arithmetic-on-void.patch b/pkg/kbd/patch/0001-Avoid-pointer-arithmetic-on-void.patch new file mode 100644 index 00000000..2b843e8d --- /dev/null +++ b/pkg/kbd/patch/0001-Avoid-pointer-arithmetic-on-void.patch @@ -0,0 +1,61 @@ +From 36ab4890a83ec2347dc1955dd8cc40095e497890 Mon Sep 17 00:00:00 2001 +From: Michael Forney <mforney@mforney.org> +Date: Tue, 12 Mar 2019 16:45:54 -0700 +Subject: [PATCH] Avoid pointer arithmetic on `void *` + +Standard C requires that the pointer operand to the + operator be to a +complete object type[0], so use a `char *` instead. + +[0] http://port70.net/~nsz/c/c11/n1570.html#6.5.6p2 +--- + src/libkeymap/array.c | 6 +++--- + src/libkeymap/keymap/array.h | 2 +- + 2 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/src/libkeymap/array.c b/src/libkeymap/array.c +index 076c1de..ec175df 100644 +--- a/src/libkeymap/array.c ++++ b/src/libkeymap/array.c +@@ -54,7 +54,7 @@ int lk_array_exists(struct lk_array *a, unsigned int i) + return 0; + } + +- s = (char *)(a->array + (a->memb * i)); ++ s = a->array + (a->memb * i); + + for (k = 0; k < a->memb; k++) { + if (s[k] != 0) +@@ -80,7 +80,7 @@ lk_array_get_ptr(struct lk_array *a, unsigned int i) + if (!a || i >= a->total) { + return NULL; + } +- ptr = a->array; ++ ptr = (void **)a->array; + return *(ptr + i); + } + +@@ -91,7 +91,7 @@ array_resize(struct lk_array *a, unsigned int i) + return -EINVAL; + + if (i >= a->total) { +- void *tmp = realloc(a->array, a->memb * (i + 1)); ++ char *tmp = realloc(a->array, a->memb * (i + 1)); + if (!tmp) + return -ENOMEM; + +diff --git a/src/libkeymap/keymap/array.h b/src/libkeymap/keymap/array.h +index 9894af1..caac6fb 100644 +--- a/src/libkeymap/keymap/array.h ++++ b/src/libkeymap/keymap/array.h +@@ -6,7 +6,7 @@ + * @details The array is designed to store an arbitrary number of similar items. + */ + struct lk_array { +- void *array; /**< Data pointer. */ ++ char *array; /**< Data pointer. */ + size_t memb; /**< One element size. */ + size_t count; /**< Number of elements. */ + size_t total; /**< Total number of allocated elements. */ +-- +2.20.1 + |
