aboutsummaryrefslogtreecommitdiffstats
path: root/samples
diff options
context:
space:
mode:
authorNicholas Mc Guire <hofrat@osadl.org>2019-01-23 20:48:16 -0500
committerJiri Kosina <jkosina@suse.cz>2019-01-25 10:43:35 -0500
commitb73d5dc72272c0012999f939476b703d269d21b6 (patch)
treef7badad5904aa7d595e47f036433dc81c8f4ac7c /samples
parenta6c34247af70053219fcfa711bfc5e0d0d954daf (diff)
livepatch: samples: non static warnings fix
Sparse reported warnings about non-static symbols. For the variables a simple static attribute is fine - for the functions referenced by livepatch via klp_func the symbol-names must be unmodified in the symbol table and the patchable code has to be emitted. The resolution is to attach __used attribute to the shared statically declared functions. Link: https://lore.kernel.org/lkml/1544965657-26804-1-git-send-email-hofrat@osadl.org/ Suggested-by: Joe Lawrence <joe.lawrence@redhat.com> Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org> Acked-by: Miroslav Benes <mbenes@suse.cz> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'samples')
-rw-r--r--samples/livepatch/livepatch-shadow-fix1.c4
-rw-r--r--samples/livepatch/livepatch-shadow-fix2.c4
-rw-r--r--samples/livepatch/livepatch-shadow-mod.c11
3 files changed, 10 insertions, 9 deletions
diff --git a/samples/livepatch/livepatch-shadow-fix1.c b/samples/livepatch/livepatch-shadow-fix1.c
index e8f1bd6b29b1..dd49c9473580 100644
--- a/samples/livepatch/livepatch-shadow-fix1.c
+++ b/samples/livepatch/livepatch-shadow-fix1.c
@@ -71,7 +71,7 @@ static int shadow_leak_ctor(void *obj, void *shadow_data, void *ctor_data)
71 return 0; 71 return 0;
72} 72}
73 73
74struct dummy *livepatch_fix1_dummy_alloc(void) 74static struct dummy *livepatch_fix1_dummy_alloc(void)
75{ 75{
76 struct dummy *d; 76 struct dummy *d;
77 void *leak; 77 void *leak;
@@ -113,7 +113,7 @@ static void livepatch_fix1_dummy_leak_dtor(void *obj, void *shadow_data)
113 __func__, d, *shadow_leak); 113 __func__, d, *shadow_leak);
114} 114}
115 115
116void livepatch_fix1_dummy_free(struct dummy *d) 116static void livepatch_fix1_dummy_free(struct dummy *d)
117{ 117{
118 void **shadow_leak; 118 void **shadow_leak;
119 119
diff --git a/samples/livepatch/livepatch-shadow-fix2.c b/samples/livepatch/livepatch-shadow-fix2.c
index b34c7bf83356..b6dac2b9f97f 100644
--- a/samples/livepatch/livepatch-shadow-fix2.c
+++ b/samples/livepatch/livepatch-shadow-fix2.c
@@ -50,7 +50,7 @@ struct dummy {
50 unsigned long jiffies_expire; 50 unsigned long jiffies_expire;
51}; 51};
52 52
53bool livepatch_fix2_dummy_check(struct dummy *d, unsigned long jiffies) 53static bool livepatch_fix2_dummy_check(struct dummy *d, unsigned long jiffies)
54{ 54{
55 int *shadow_count; 55 int *shadow_count;
56 56
@@ -78,7 +78,7 @@ static void livepatch_fix2_dummy_leak_dtor(void *obj, void *shadow_data)
78 __func__, d, *shadow_leak); 78 __func__, d, *shadow_leak);
79} 79}
80 80
81void livepatch_fix2_dummy_free(struct dummy *d) 81static void livepatch_fix2_dummy_free(struct dummy *d)
82{ 82{
83 void **shadow_leak; 83 void **shadow_leak;
84 int *shadow_count; 84 int *shadow_count;
diff --git a/samples/livepatch/livepatch-shadow-mod.c b/samples/livepatch/livepatch-shadow-mod.c
index 4aa8a88d3cd6..4d79c6dc055b 100644
--- a/samples/livepatch/livepatch-shadow-mod.c
+++ b/samples/livepatch/livepatch-shadow-mod.c
@@ -96,15 +96,15 @@ MODULE_DESCRIPTION("Buggy module for shadow variable demo");
96 * Keep a list of all the dummies so we can clean up any residual ones 96 * Keep a list of all the dummies so we can clean up any residual ones
97 * on module exit 97 * on module exit
98 */ 98 */
99LIST_HEAD(dummy_list); 99static LIST_HEAD(dummy_list);
100DEFINE_MUTEX(dummy_list_mutex); 100static DEFINE_MUTEX(dummy_list_mutex);
101 101
102struct dummy { 102struct dummy {
103 struct list_head list; 103 struct list_head list;
104 unsigned long jiffies_expire; 104 unsigned long jiffies_expire;
105}; 105};
106 106
107noinline struct dummy *dummy_alloc(void) 107static __used noinline struct dummy *dummy_alloc(void)
108{ 108{
109 struct dummy *d; 109 struct dummy *d;
110 void *leak; 110 void *leak;
@@ -129,7 +129,7 @@ noinline struct dummy *dummy_alloc(void)
129 return d; 129 return d;
130} 130}
131 131
132noinline void dummy_free(struct dummy *d) 132static __used noinline void dummy_free(struct dummy *d)
133{ 133{
134 pr_info("%s: dummy @ %p, expired = %lx\n", 134 pr_info("%s: dummy @ %p, expired = %lx\n",
135 __func__, d, d->jiffies_expire); 135 __func__, d, d->jiffies_expire);
@@ -137,7 +137,8 @@ noinline void dummy_free(struct dummy *d)
137 kfree(d); 137 kfree(d);
138} 138}
139 139
140noinline bool dummy_check(struct dummy *d, unsigned long jiffies) 140static __used noinline bool dummy_check(struct dummy *d,
141 unsigned long jiffies)
141{ 142{
142 return time_after(jiffies, d->jiffies_expire); 143 return time_after(jiffies, d->jiffies_expire);
143} 144}