SHA256
1
0
forked from pool/kmod
kmod/tools-depmod-fix-Walloc-size.patch
Jan Engelhardt 4970184c4d Accepting request 1131480 from home:michals
- Add upstream fixes since v31
  * tools-depmod-fix-Walloc-size.patch
  * libkmod-remove-pkcs7-obj_to_hash_algo.patch
  * configure-Check-that-provided-paths-are-absolute.patch
- Refresh usrmerge patches to upstream version (cosmetic change only)

OBS-URL: https://build.opensuse.org/request/show/1131480
OBS-URL: https://build.opensuse.org/package/show/Base:System/kmod?expand=0&rev=234
2023-12-07 07:44:14 +00:00

74 lines
2.8 KiB
Diff
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

From 3af2f475b0b729f20279f2ce488cc9f727f0b763 Mon Sep 17 00:00:00 2001
From: Sam James <sam@gentoo.org>
Date: Sun, 5 Nov 2023 22:02:25 +0000
Subject: [PATCH 5/9] tools: depmod: fix -Walloc-size
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
GCC 14 introduces a new -Walloc-size included in -Wextra which gives:
```
tools/depmod.c:192:14: warning: allocation of insufficient size 1 for type struct index_node with size 1048 [-Walloc-size]
tools/depmod.c:255:11: warning: allocation of insufficient size 1 for type struct index_value with size 16 [-Walloc-size]
tools/depmod.c:286:35: warning: allocation of insufficient size 1 for type struct index_node with size 1048 [-Walloc-size]
tools/depmod.c:315:44: warning: allocation of insufficient size 1 for type struct index_node with size 1048 [-Walloc-size]
```
The calloc prototype is:
```
void *calloc(size_t nmemb, size_t size);
```
So, just swap the number of members and size arguments to match the prototype, as
we're initialising 1 struct of size `sizeof(struct ...)`. GCC then sees we're not
doing anything wrong.
Signed-off-by: Sam James <sam@gentoo.org>
---
tools/depmod.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/tools/depmod.c b/tools/depmod.c
index 630fef9c8fb0..ab8513b21526 100644
--- a/tools/depmod.c
+++ b/tools/depmod.c
@@ -190,7 +190,7 @@ static struct index_node *index_create(void)
{
struct index_node *node;
- node = NOFAIL(calloc(sizeof(struct index_node), 1));
+ node = NOFAIL(calloc(1, sizeof(struct index_node)));
node->prefix = NOFAIL(strdup(""));
node->first = INDEX_CHILDMAX;
@@ -253,7 +253,7 @@ static int index_add_value(struct index_value **values,
values = &(*values)->next;
len = strlen(value);
- v = NOFAIL(calloc(sizeof(struct index_value) + len + 1, 1));
+ v = NOFAIL(calloc(1, sizeof(struct index_value) + len + 1));
v->next = *values;
v->priority = priority;
memcpy(v->value, value, len + 1);
@@ -284,7 +284,7 @@ static int index_insert(struct index_node *node, const char *key,
struct index_node *n;
/* New child is copy of node with prefix[j+1..N] */
- n = NOFAIL(calloc(sizeof(struct index_node), 1));
+ n = NOFAIL(calloc(1, sizeof(struct index_node)));
memcpy(n, node, sizeof(struct index_node));
n->prefix = NOFAIL(strdup(&prefix[j+1]));
@@ -313,7 +313,7 @@ static int index_insert(struct index_node *node, const char *key,
node->first = ch;
if (ch > node->last)
node->last = ch;
- node->children[ch] = NOFAIL(calloc(sizeof(struct index_node), 1));
+ node->children[ch] = NOFAIL(calloc(1, sizeof(struct index_node)));
child = node->children[ch];
child->prefix = NOFAIL(strdup(&key[i+1]));
--
2.42.0