Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AndroidKernelMSM
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Werner Sembach
AndroidKernelMSM
Commits
e35436dc
Commit
e35436dc
authored
6 years ago
by
Werner Sembach
Browse files
Options
Downloads
Patches
Plain Diff
Pack k_list and list_size into a struct to prevent variable reordering
parent
1df03d1a
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
drivers/klist/klist.c
+22
-20
22 additions, 20 deletions
drivers/klist/klist.c
with
22 additions
and
20 deletions
drivers/klist/klist.c
+
22
−
20
View file @
e35436dc
...
@@ -33,8 +33,10 @@
...
@@ -33,8 +33,10 @@
/* consts */
/* consts */
#define MAX_SIZE 0x400
#define MAX_SIZE 0x400
static
long
k_list
[
MAX_SIZE
];
static
struct
k_list
{
static
unsigned
long
list_size
;
long
values
[
MAX_SIZE
];
unsigned
long
size
;
}
list
;
struct
index_val_t
{
struct
index_val_t
{
unsigned
long
index
;
unsigned
long
index
;
...
@@ -43,10 +45,10 @@ struct index_val_t {
...
@@ -43,10 +45,10 @@ struct index_val_t {
long
add_item
(
long
arg
)
long
add_item
(
long
arg
)
{
{
if
(
list
_
size
>=
MAX_SIZE
)
if
(
list
.
size
>=
MAX_SIZE
)
return
-
EINVAL
;
return
-
EINVAL
;
k_
list
[
list
_
size
]
=
arg
;
list
.
values
[
list
.
size
]
=
arg
;
list
_
size
++
;
list
.
size
++
;
return
0
;
return
0
;
}
}
...
@@ -58,17 +60,17 @@ long insert_item(long arg)
...
@@ -58,17 +60,17 @@ long insert_item(long arg)
if
(
copy_from_user
((
void
*
)
&
io
,
(
void
__user
*
)
arg
,
sizeof
(
struct
index_val_t
)))
if
(
copy_from_user
((
void
*
)
&
io
,
(
void
__user
*
)
arg
,
sizeof
(
struct
index_val_t
)))
return
-
EINVAL
;
return
-
EINVAL
;
if
(
list
_
size
>=
MAX_SIZE
)
if
(
list
.
size
>=
MAX_SIZE
)
return
-
EINVAL
;
return
-
EINVAL
;
if
(
io
.
index
>
list
_
size
)
if
(
io
.
index
>
list
.
size
)
return
-
EINVAL
;
return
-
EINVAL
;
for
(
i
=
list
_
size
;
i
>
io
.
index
;
i
--
)
for
(
i
=
list
.
size
;
i
>
io
.
index
;
i
--
)
{
{
k_
list
[
i
]
=
k_
list
[
i
-
1
];
list
.
values
[
i
]
=
list
.
values
[
i
-
1
];
}
}
k_
list
[
io
.
index
]
=
io
.
value
;
list
.
values
[
io
.
index
]
=
io
.
value
;
list
_
size
++
;
list
.
size
++
;
return
0
;
return
0
;
}
}
...
@@ -79,10 +81,10 @@ long set_item(long arg)
...
@@ -79,10 +81,10 @@ long set_item(long arg)
if
(
copy_from_user
((
void
*
)
&
io
,
(
void
__user
*
)
arg
,
sizeof
(
struct
index_val_t
)))
if
(
copy_from_user
((
void
*
)
&
io
,
(
void
__user
*
)
arg
,
sizeof
(
struct
index_val_t
)))
return
-
EINVAL
;
return
-
EINVAL
;
if
(
io
.
index
>=
list
_
size
)
if
(
io
.
index
>=
list
.
size
)
return
-
EINVAL
;
return
-
EINVAL
;
k_
list
[
io
.
index
]
=
io
.
value
;
list
.
values
[
io
.
index
]
=
io
.
value
;
return
0
;
return
0
;
}
}
...
@@ -93,10 +95,10 @@ long get_item(long arg)
...
@@ -93,10 +95,10 @@ long get_item(long arg)
if
(
copy_from_user
((
void
*
)
&
io
,
(
void
__user
*
)
arg
,
sizeof
(
struct
index_val_t
)))
if
(
copy_from_user
((
void
*
)
&
io
,
(
void
__user
*
)
arg
,
sizeof
(
struct
index_val_t
)))
return
-
EINVAL
;
return
-
EINVAL
;
if
(
io
.
index
>=
list
_
size
)
if
(
io
.
index
>=
list
.
size
)
return
-
EINVAL
;
return
-
EINVAL
;
io
.
value
=
k_
list
[
io
.
index
];
io
.
value
=
list
.
values
[
io
.
index
];
if
(
copy_to_user
((
void
__user
*
)
arg
,
(
void
*
)
&
io
,
sizeof
(
struct
index_val_t
)))
if
(
copy_to_user
((
void
__user
*
)
arg
,
(
void
*
)
&
io
,
sizeof
(
struct
index_val_t
)))
return
-
EINVAL
;
return
-
EINVAL
;
...
@@ -107,14 +109,14 @@ long delete_item(long arg)
...
@@ -107,14 +109,14 @@ long delete_item(long arg)
{
{
unsigned
long
index
=
arg
;
unsigned
long
index
=
arg
;
if
(
index
>=
list
_
size
)
if
(
index
>=
list
.
size
)
return
-
EINVAL
;
return
-
EINVAL
;
for
(;
index
<
list
_
size
-
1
;
index
++
)
for
(;
index
<
list
.
size
-
1
;
index
++
)
{
{
k_
list
[
index
]
=
k_
list
[
index
+
1
];
list
.
values
[
index
]
=
list
.
values
[
index
+
1
];
}
}
list
_
size
--
;
list
.
size
--
;
return
0
;
return
0
;
}
}
...
@@ -180,7 +182,7 @@ static int __init init_list(void)
...
@@ -180,7 +182,7 @@ static int __init init_list(void)
ret
=
misc_register
(
&
klist
);
ret
=
misc_register
(
&
klist
);
LOG
(
"register device: %d
\n
"
,
ret
);
LOG
(
"register device: %d
\n
"
,
ret
);
list
_
size
=
0
;
list
.
size
=
0
;
return
ret
;
return
ret
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment