Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
19e4e57a
Commit
19e4e57a
authored
Jun 03, 2003
by
Christoph Hellwig
Committed by
David S. Miller
Jun 03, 2003
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[NET]: Fix coding style in net/core/iovec.c
parent
4cb5e616
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
82 deletions
+58
-82
net/core/iovec.c
net/core/iovec.c
+58
-82
No files found.
net/core/iovec.c
View file @
19e4e57a
...
@@ -41,35 +41,35 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, char *address, int mode)
...
@@ -41,35 +41,35 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, char *address, int mode)
{
{
int
size
,
err
,
ct
;
int
size
,
err
,
ct
;
if
(
m
->
msg_namelen
)
if
(
m
->
msg_namelen
)
{
{
if
(
mode
==
VERIFY_READ
)
{
if
(
mode
==
VERIFY_READ
)
err
=
move_addr_to_kernel
(
m
->
msg_name
,
m
->
msg_namelen
,
{
address
);
err
=
move_addr_to_kernel
(
m
->
msg_name
,
m
->
msg_namelen
,
address
);
if
(
err
<
0
)
if
(
err
<
0
)
return
err
;
goto
out
;
m
->
msg_name
=
address
;
}
}
else
m
->
msg_name
=
NULL
;
m
->
msg_name
=
address
;
}
}
else
m
->
msg_name
=
NULL
;
err
=
-
EFAULT
;
size
=
m
->
msg_iovlen
*
sizeof
(
struct
iovec
);
size
=
m
->
msg_iovlen
*
sizeof
(
struct
iovec
);
if
(
copy_from_user
(
iov
,
m
->
msg_iov
,
size
))
if
(
copy_from_user
(
iov
,
m
->
msg_iov
,
size
))
goto
out
;
return
-
EFAULT
;
m
->
msg_iov
=
iov
;
for
(
err
=
0
,
ct
=
0
;
ct
<
m
->
msg_iovlen
;
ct
++
)
{
m
->
msg_iov
=
iov
;
err
=
0
;
for
(
ct
=
0
;
ct
<
m
->
msg_iovlen
;
ct
++
)
{
err
+=
iov
[
ct
].
iov_len
;
err
+=
iov
[
ct
].
iov_len
;
/* Goal is not to verify user data, but to prevent returning
/*
negative value, which is interpreted as errno.
* Goal is not to verify user data, but to prevent returning
Overflow is still possible, but it is harmless.
* negative value, which is interpreted as errno.
* Overflow is still possible, but it is harmless.
*/
*/
if
(
err
<
0
)
if
(
err
<
0
)
return
-
EMSGSIZE
;
return
-
EMSGSIZE
;
}
}
out:
return
err
;
return
err
;
}
}
...
@@ -81,25 +81,20 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, char *address, int mode)
...
@@ -81,25 +81,20 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, char *address, int mode)
int
memcpy_toiovec
(
struct
iovec
*
iov
,
unsigned
char
*
kdata
,
int
len
)
int
memcpy_toiovec
(
struct
iovec
*
iov
,
unsigned
char
*
kdata
,
int
len
)
{
{
int
err
=
-
EFAULT
;
while
(
len
>
0
)
{
if
(
iov
->
iov_len
)
{
while
(
len
>
0
)
{
if
(
iov
->
iov_len
)
{
int
copy
=
min_t
(
unsigned
int
,
iov
->
iov_len
,
len
);
int
copy
=
min_t
(
unsigned
int
,
iov
->
iov_len
,
len
);
if
(
copy_to_user
(
iov
->
iov_base
,
kdata
,
copy
))
if
(
copy_to_user
(
iov
->
iov_base
,
kdata
,
copy
))
goto
out
;
return
-
EFAULT
;
kdata
+=
copy
;
kdata
+=
copy
;
len
-=
copy
;
len
-=
copy
;
iov
->
iov_len
-=
copy
;
iov
->
iov_len
-=
copy
;
iov
->
iov_base
+=
copy
;
iov
->
iov_base
+=
copy
;
}
}
iov
++
;
iov
++
;
}
}
err
=
0
;
out:
return
0
;
return
err
;
}
}
/*
/*
...
@@ -110,16 +105,14 @@ int memcpy_toiovec(struct iovec *iov, unsigned char *kdata, int len)
...
@@ -110,16 +105,14 @@ int memcpy_toiovec(struct iovec *iov, unsigned char *kdata, int len)
void
memcpy_tokerneliovec
(
struct
iovec
*
iov
,
unsigned
char
*
kdata
,
int
len
)
void
memcpy_tokerneliovec
(
struct
iovec
*
iov
,
unsigned
char
*
kdata
,
int
len
)
{
{
while
(
len
>
0
)
while
(
len
>
0
)
{
{
if
(
iov
->
iov_len
)
{
if
(
iov
->
iov_len
)
{
int
copy
=
min_t
(
unsigned
int
,
iov
->
iov_len
,
len
);
int
copy
=
min_t
(
unsigned
int
,
iov
->
iov_len
,
len
);
memcpy
(
iov
->
iov_base
,
kdata
,
copy
);
memcpy
(
iov
->
iov_base
,
kdata
,
copy
);
kdata
+=
copy
;
kdata
+=
copy
;
len
-=
copy
;
len
-=
copy
;
iov
->
iov_len
-=
copy
;
iov
->
iov_len
-=
copy
;
iov
->
iov_base
+=
copy
;
iov
->
iov_base
+=
copy
;
}
}
iov
++
;
iov
++
;
}
}
...
@@ -134,59 +127,47 @@ void memcpy_tokerneliovec(struct iovec *iov, unsigned char *kdata, int len)
...
@@ -134,59 +127,47 @@ void memcpy_tokerneliovec(struct iovec *iov, unsigned char *kdata, int len)
int
memcpy_fromiovec
(
unsigned
char
*
kdata
,
struct
iovec
*
iov
,
int
len
)
int
memcpy_fromiovec
(
unsigned
char
*
kdata
,
struct
iovec
*
iov
,
int
len
)
{
{
int
err
=
-
EFAULT
;
while
(
len
>
0
)
{
if
(
iov
->
iov_len
)
{
while
(
len
>
0
)
{
if
(
iov
->
iov_len
)
{
int
copy
=
min_t
(
unsigned
int
,
len
,
iov
->
iov_len
);
int
copy
=
min_t
(
unsigned
int
,
len
,
iov
->
iov_len
);
if
(
copy_from_user
(
kdata
,
iov
->
iov_base
,
copy
))
if
(
copy_from_user
(
kdata
,
iov
->
iov_base
,
copy
))
goto
out
;
return
-
EFAULT
;
len
-=
copy
;
len
-=
copy
;
kdata
+=
copy
;
kdata
+=
copy
;
iov
->
iov_base
+=
copy
;
iov
->
iov_base
+=
copy
;
iov
->
iov_len
-=
copy
;
iov
->
iov_len
-=
copy
;
}
}
iov
++
;
iov
++
;
}
}
err
=
0
;
out:
return
err
;
}
return
0
;
}
/*
/*
* For use with ip_build_xmit
* For use with ip_build_xmit
*/
*/
int
memcpy_fromiovecend
(
unsigned
char
*
kdata
,
struct
iovec
*
iov
,
int
offset
,
int
memcpy_fromiovecend
(
unsigned
char
*
kdata
,
struct
iovec
*
iov
,
int
offset
,
int
len
)
int
len
)
{
{
int
err
=
-
EFAULT
;
/* Skip over the finished iovecs */
/* Skip over the finished iovecs */
while
(
offset
>=
iov
->
iov_len
)
while
(
offset
>=
iov
->
iov_len
)
{
{
offset
-=
iov
->
iov_len
;
offset
-=
iov
->
iov_len
;
iov
++
;
iov
++
;
}
}
while
(
len
>
0
)
while
(
len
>
0
)
{
{
u8
*
base
=
iov
->
iov_base
+
offset
;
u8
*
base
=
iov
->
iov_base
+
offset
;
int
copy
=
min_t
(
unsigned
int
,
len
,
iov
->
iov_len
-
offset
);
int
copy
=
min_t
(
unsigned
int
,
len
,
iov
->
iov_len
-
offset
);
offset
=
0
;
offset
=
0
;
if
(
copy_from_user
(
kdata
,
base
,
copy
))
if
(
copy_from_user
(
kdata
,
base
,
copy
))
goto
out
;
return
-
EFAULT
;
len
-=
copy
;
len
-=
copy
;
kdata
+=
copy
;
kdata
+=
copy
;
iov
++
;
iov
++
;
}
}
err
=
0
;
out:
return
0
;
return
err
;
}
}
/*
/*
...
@@ -197,7 +178,6 @@ int memcpy_fromiovecend(unsigned char *kdata, struct iovec *iov, int offset,
...
@@ -197,7 +178,6 @@ int memcpy_fromiovecend(unsigned char *kdata, struct iovec *iov, int offset,
* ip_build_xmit must ensure that when fragmenting only the last
* ip_build_xmit must ensure that when fragmenting only the last
* call to this function will be unaligned also.
* call to this function will be unaligned also.
*/
*/
int
csum_partial_copy_fromiovecend
(
unsigned
char
*
kdata
,
struct
iovec
*
iov
,
int
csum_partial_copy_fromiovecend
(
unsigned
char
*
kdata
,
struct
iovec
*
iov
,
int
offset
,
unsigned
int
len
,
int
*
csump
)
int
offset
,
unsigned
int
len
,
int
*
csump
)
{
{
...
@@ -205,21 +185,19 @@ int csum_partial_copy_fromiovecend(unsigned char *kdata, struct iovec *iov,
...
@@ -205,21 +185,19 @@ int csum_partial_copy_fromiovecend(unsigned char *kdata, struct iovec *iov,
int
partial_cnt
=
0
,
err
=
0
;
int
partial_cnt
=
0
,
err
=
0
;
/* Skip over the finished iovecs */
/* Skip over the finished iovecs */
while
(
offset
>=
iov
->
iov_len
)
while
(
offset
>=
iov
->
iov_len
)
{
{
offset
-=
iov
->
iov_len
;
offset
-=
iov
->
iov_len
;
iov
++
;
iov
++
;
}
}
while
(
len
>
0
)
while
(
len
>
0
)
{
{
u8
*
base
=
iov
->
iov_base
+
offset
;
u8
*
base
=
iov
->
iov_base
+
offset
;
int
copy
=
min_t
(
unsigned
int
,
len
,
iov
->
iov_len
-
offset
);
int
copy
=
min_t
(
unsigned
int
,
len
,
iov
->
iov_len
-
offset
);
offset
=
0
;
offset
=
0
;
/* There is a remnant from previous iov. */
/* There is a remnant from previous iov. */
if
(
partial_cnt
)
if
(
partial_cnt
)
{
{
int
par_len
=
4
-
partial_cnt
;
int
par_len
=
4
-
partial_cnt
;
/* iov component is too short ... */
/* iov component is too short ... */
...
@@ -227,9 +205,9 @@ int csum_partial_copy_fromiovecend(unsigned char *kdata, struct iovec *iov,
...
@@ -227,9 +205,9 @@ int csum_partial_copy_fromiovecend(unsigned char *kdata, struct iovec *iov,
if
(
copy_from_user
(
kdata
,
base
,
copy
))
if
(
copy_from_user
(
kdata
,
base
,
copy
))
goto
out_fault
;
goto
out_fault
;
kdata
+=
copy
;
kdata
+=
copy
;
base
+=
copy
;
base
+=
copy
;
partial_cnt
+=
copy
;
partial_cnt
+=
copy
;
len
-=
copy
;
len
-=
copy
;
iov
++
;
iov
++
;
if
(
len
)
if
(
len
)
continue
;
continue
;
...
@@ -247,11 +225,9 @@ int csum_partial_copy_fromiovecend(unsigned char *kdata, struct iovec *iov,
...
@@ -247,11 +225,9 @@ int csum_partial_copy_fromiovecend(unsigned char *kdata, struct iovec *iov,
partial_cnt
=
0
;
partial_cnt
=
0
;
}
}
if
(
len
>
copy
)
if
(
len
>
copy
)
{
{
partial_cnt
=
copy
%
4
;
partial_cnt
=
copy
%
4
;
if
(
partial_cnt
)
if
(
partial_cnt
)
{
{
copy
-=
partial_cnt
;
copy
-=
partial_cnt
;
if
(
copy_from_user
(
kdata
+
copy
,
base
+
copy
,
if
(
copy_from_user
(
kdata
+
copy
,
base
+
copy
,
partial_cnt
))
partial_cnt
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment