aboutsummaryrefslogtreecommitdiff
path: root/slof
diff options
context:
space:
mode:
authorAlexey Kardashevskiy <aik@ozlabs.ru>2021-01-27 19:37:39 +1100
committerAlexey Kardashevskiy <aik@ozlabs.ru>2021-02-12 13:46:16 +1100
commit071a09ef070a5eff57c7548be5cdb1bb76c68c23 (patch)
treedec5699da4f786d77e81328fbb76c52e088b80f2 /slof
parente244301a3192c91ceed8daf8c03afa1c88328e7e (diff)
downloadSLOF-071a09ef070a5eff57c7548be5cdb1bb76c68c23.zip
SLOF-071a09ef070a5eff57c7548be5cdb1bb76c68c23.tar.gz
SLOF-071a09ef070a5eff57c7548be5cdb1bb76c68c23.tar.bz2
libnet: Compile with -Wextra
-Wextra enables a bunch of rather useful checks which this fixes. This also fixes unused parameters warning by passing meaningful value and doing sanity checks. Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> --- Changes: v2: * updated commit log about using AF_INET/etc * replaced cast to int with size_t in pxelinux_load_cfg * added (alen == 0) in ping()
Diffstat (limited to 'slof')
-rw-r--r--slof/ppc64.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/slof/ppc64.c b/slof/ppc64.c
index 83a8e82..ca6caff 100644
--- a/slof/ppc64.c
+++ b/slof/ppc64.c
@@ -144,6 +144,12 @@ int socket(int domain, int type, int proto, char *mac_addr)
int prop_len;
int fd;
+ if (!(domain == AF_INET || domain == AF_INET6))
+ return -1;
+
+ if (type != SOCK_DGRAM || proto != 0)
+ return -1;
+
/* search free file descriptor (and skip stdio handlers) */
for (fd = 3; fd < FILEIO_MAX; ++fd) {
if (fd_array[fd].type == FILEIO_TYPE_EMPTY) {
@@ -217,7 +223,7 @@ int close(int fd)
*/
int recv(int fd, void *buf, int len, int flags)
{
- if (!is_valid_fd(fd))
+ if (!is_valid_fd(fd) || flags)
return -1;
forth_push((unsigned long)buf);
@@ -237,7 +243,7 @@ int recv(int fd, void *buf, int len, int flags)
*/
int send(int fd, const void *buf, int len, int flags)
{
- if (!is_valid_fd(fd))
+ if (!is_valid_fd(fd) || flags)
return -1;
forth_push((unsigned long)buf);
@@ -258,7 +264,7 @@ int send(int fd, const void *buf, int len, int flags)
ssize_t read(int fd, void *buf, size_t len)
{
char *ptr = (char *)buf;
- int cnt = 0;
+ unsigned cnt = 0;
char code;
if (fd == 0 || fd == 2) {