Commit b73d5dc7 authored by Nicholas Mc Guire's avatar Nicholas Mc Guire Committed by Jiri Kosina

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: default avatarJoe Lawrence <joe.lawrence@redhat.com>
Signed-off-by: default avatarNicholas Mc Guire <hofrat@osadl.org>
Acked-by: default avatarMiroslav Benes <mbenes@suse.cz>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent a6c34247
......@@ -71,7 +71,7 @@ static int shadow_leak_ctor(void *obj, void *shadow_data, void *ctor_data)
return 0;
}
struct dummy *livepatch_fix1_dummy_alloc(void)
static struct dummy *livepatch_fix1_dummy_alloc(void)
{
struct dummy *d;
void *leak;
......@@ -113,7 +113,7 @@ static void livepatch_fix1_dummy_leak_dtor(void *obj, void *shadow_data)
__func__, d, *shadow_leak);
}
void livepatch_fix1_dummy_free(struct dummy *d)
static void livepatch_fix1_dummy_free(struct dummy *d)
{
void **shadow_leak;
......
......@@ -50,7 +50,7 @@ struct dummy {
unsigned long jiffies_expire;
};
bool livepatch_fix2_dummy_check(struct dummy *d, unsigned long jiffies)
static bool livepatch_fix2_dummy_check(struct dummy *d, unsigned long jiffies)
{
int *shadow_count;
......@@ -78,7 +78,7 @@ static void livepatch_fix2_dummy_leak_dtor(void *obj, void *shadow_data)
__func__, d, *shadow_leak);
}
void livepatch_fix2_dummy_free(struct dummy *d)
static void livepatch_fix2_dummy_free(struct dummy *d)
{
void **shadow_leak;
int *shadow_count;
......
......@@ -96,15 +96,15 @@ MODULE_DESCRIPTION("Buggy module for shadow variable demo");
* Keep a list of all the dummies so we can clean up any residual ones
* on module exit
*/
LIST_HEAD(dummy_list);
DEFINE_MUTEX(dummy_list_mutex);
static LIST_HEAD(dummy_list);
static DEFINE_MUTEX(dummy_list_mutex);
struct dummy {
struct list_head list;
unsigned long jiffies_expire;
};
noinline struct dummy *dummy_alloc(void)
static __used noinline struct dummy *dummy_alloc(void)
{
struct dummy *d;
void *leak;
......@@ -129,7 +129,7 @@ noinline struct dummy *dummy_alloc(void)
return d;
}
noinline void dummy_free(struct dummy *d)
static __used noinline void dummy_free(struct dummy *d)
{
pr_info("%s: dummy @ %p, expired = %lx\n",
__func__, d, d->jiffies_expire);
......@@ -137,7 +137,8 @@ noinline void dummy_free(struct dummy *d)
kfree(d);
}
noinline bool dummy_check(struct dummy *d, unsigned long jiffies)
static __used noinline bool dummy_check(struct dummy *d,
unsigned long jiffies)
{
return time_after(jiffies, d->jiffies_expire);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment