summaryrefslogtreecommitdiffstats
path: root/recipes-support
diff options
context:
space:
mode:
authorChristopher Larson <chris_larson@mentor.com>2016-02-15 17:00:50 -0700
committerChristopher Larson <chris_larson@mentor.com>2016-02-15 17:21:34 -0700
commit775ed0bfd501fe21ba52ace5d651de53905a7513 (patch)
tree217ef292bc28e52a7dfa0232b44a6551305f4e1f /recipes-support
parente9def8f1a701e999aace6875195c933545f3c98e (diff)
downloadmeta-clang-775ed0bfd501fe21ba52ace5d651de53905a7513.tar.gz
rng-tools: fix build with clang
This fixes 'error: fields must have a constant size' by allocating it with the given buffer size dynamically. Signed-off-by: Christopher Larson <chris_larson@mentor.com>
Diffstat (limited to 'recipes-support')
-rw-r--r--recipes-support/rng-tools/rng-tools/When-adding-entropy-allocate-the-struct-dynamically.patch50
-rw-r--r--recipes-support/rng-tools/rng-tools_5.bbappend3
2 files changed, 53 insertions, 0 deletions
diff --git a/recipes-support/rng-tools/rng-tools/When-adding-entropy-allocate-the-struct-dynamically.patch b/recipes-support/rng-tools/rng-tools/When-adding-entropy-allocate-the-struct-dynamically.patch
new file mode 100644
index 0000000..9bed536
--- /dev/null
+++ b/recipes-support/rng-tools/rng-tools/When-adding-entropy-allocate-the-struct-dynamically.patch
@@ -0,0 +1,50 @@
1From 27f234a1bb97f7196466a3535a072fda1b66ea1e Mon Sep 17 00:00:00 2001
2From: Christopher Larson <chris_larson@mentor.com>
3Date: Mon, 15 Feb 2016 16:46:46 -0700
4Subject: [PATCH] When adding entropy, allocate the struct dynamically
5
6Clang/LLVM does not support struct fields without a constant size. Also, we
7can use the existing struct defined by linux/random.h.
8
9Upstream-Status: Pending
10Signed-off-by: Christopher Larson <chris_larson@mentor.com>
11---
12 rngd_linux.c | 16 +++++++---------
13 1 file changed, 7 insertions(+), 9 deletions(-)
14
15diff --git a/rngd_linux.c b/rngd_linux.c
16index c4f45de..8f6cca7 100644
17--- a/rngd_linux.c
18+++ b/rngd_linux.c
19@@ -120,21 +120,19 @@ void init_kernel_rng(const char* randomdev)
20
21 void random_add_entropy(void *buf, size_t size)
22 {
23- struct {
24- int ent_count;
25- int size;
26- unsigned char data[size];
27- } entropy;
28+ struct rand_pool_info *entropy = malloc(sizeof(struct rand_pool_info) + size);
29
30- entropy.ent_count = size * 8;
31- entropy.size = size;
32- memcpy(entropy.data, buf, size);
33+ entropy->entropy_count = size * 8;
34+ entropy->buf_size = size;
35+ memcpy(entropy->buf, buf, size);
36
37- if (ioctl(random_fd, RNDADDENTROPY, &entropy) != 0) {
38+ if (ioctl(random_fd, RNDADDENTROPY, entropy) != 0) {
39 message(LOG_DAEMON|LOG_ERR, "RNDADDENTROPY failed: %s\n",
40 strerror(errno));
41+ free(entropy);
42 exit(1);
43 }
44+ free(entropy);
45 }
46
47 void random_sleep(void)
48--
492.2.1
50
diff --git a/recipes-support/rng-tools/rng-tools_5.bbappend b/recipes-support/rng-tools/rng-tools_5.bbappend
new file mode 100644
index 0000000..6d5aec4
--- /dev/null
+++ b/recipes-support/rng-tools/rng-tools_5.bbappend
@@ -0,0 +1,3 @@
1FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
2
3SRC_URI += "file://When-adding-entropy-allocate-the-struct-dynamically.patch"