Skip to content

Commit 580e00f

Browse files
committed
[syscall] readv & writev clean-up - MR #207
Signed-off-by: Jean-Pierre Miceli <jean-pierre.miceli@heig-vd.ch>
1 parent 2919321 commit 580e00f

File tree

3 files changed

+9
-14
lines changed

3 files changed

+9
-14
lines changed

so3/fs/vfs.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -422,8 +422,6 @@ static int do_read(int fd, void *buffer, int count)
422422
return ret;
423423
}
424424

425-
426-
427425
/* Low Level write */
428426
static int do_write(int fd, const void *buffer, int count)
429427
{
@@ -844,12 +842,11 @@ SYSCALL_DEFINE3(fcntl, int, fd, unsigned long, cmd, unsigned long, args)
844842
SYSCALL_DEFINE3(writev, unsigned long, fd, const struct iovec *, vec, unsigned long, vlen)
845843
{
846844
int i;
847-
int ret;
845+
int ret = 0;
848846
int total = 0;
849847

850848
for (i = 0; i < vlen; i++) {
851-
ret = do_write(fd, (const void *)vec[i].iov_base, vec[i].iov_len);
852-
ret = do_read(fd, vec[i].iov_base, vec[i].iov_len);
849+
ret = do_write(fd, (const void *) vec[i].iov_base, vec[i].iov_len);
853850
if (ret < 0) {
854851
break;
855852
} else if ((ret >= 0) && (ret < vec[i].iov_len)) {
@@ -866,11 +863,10 @@ SYSCALL_DEFINE3(writev, unsigned long, fd, const struct iovec *, vec, unsigned l
866863
return total;
867864
}
868865

869-
SYSCALL_DEFINE3(readv, unsigned long, fd, const struct iovec *, vec,
870-
unsigned long, vlen)
866+
SYSCALL_DEFINE3(readv, unsigned long, fd, const struct iovec *, vec, unsigned long, vlen)
871867
{
872868
int i;
873-
int ret;
869+
int ret = 0;
874870
int total = 0;
875871

876872
for (i = 0; i < vlen; i++) {

so3/include/syscall.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
#define SYSCALL_DEFINE0(name) \
9696
long __sys_##name(syscall_args_t *unused) \
9797
{ \
98-
return sys_do_##name(); \
98+
return sys_do_##name(); \
9999
} \
100100
inline long sys_do_##name(void)
101101
#define SYSCALL_DEFINE1(...) __SYSCALL_DEFINEx(1, __VA_ARGS__)
@@ -105,11 +105,11 @@
105105
#define SYSCALL_DEFINE5(...) __SYSCALL_DEFINEx(5, __VA_ARGS__)
106106
#define SYSCALL_DEFINE6(...) __SYSCALL_DEFINEx(6, __VA_ARGS__)
107107

108-
#define __SYSCALL_DEFINEx(x, name, ...) \
109-
long __sys_##name(syscall_args_t *args) \
110-
{ \
108+
#define __SYSCALL_DEFINEx(x, name, ...) \
109+
long __sys_##name(syscall_args_t *args) \
110+
{ \
111111
return sys_do_##name(__MAP_ARGS(x, args->args, __VA_ARGS__)); \
112-
} \
112+
} \
113113
inline long sys_do_##name(__MAP(x, __M_DECL, __VA_ARGS__))
114114

115115
typedef struct {

so3/include/vfs.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ struct iovec {
110110

111111
#define iovec iovec
112112

113-
114113
struct file_operations {
115114
int (*open)(int fd, const char *path);
116115
int (*close)(int fd);

0 commit comments

Comments
 (0)