Browse Source

disk: fix bugs detected by coverity

Nathalie Furmento 9 years ago
parent
commit
534e9acd5b
2 changed files with 5 additions and 2 deletions
  1. 2 1
      src/core/disk_ops/disk_stdio.c
  2. 3 1
      tests/disk/disk_compute.c

+ 2 - 1
src/core/disk_ops/disk_stdio.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2013 Corentin Salingue
- * Copyright (C) 2015 CNRS
+ * Copyright (C) 2015, 2016 CNRS
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -239,6 +239,7 @@ static int starpu_stdio_full_read(void *base STARPU_ATTRIBUTE_UNUSED, void *obj,
 	int res = fseek(f, 0, SEEK_END);
 	STARPU_ASSERT_MSG(res == 0, "Stdio write failed");
 	*size = ftell(f);
+	STARPU_ASSERT_MSG(*size >= 0, "Stdio write failed");
 
 	if (tmp->file)
 		STARPU_PTHREAD_MUTEX_UNLOCK(&tmp->mutex);

+ 3 - 1
tests/disk/disk_compute.c

@@ -1,7 +1,7 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
  * Copyright (C) 2013 Corentin Salingue
- * Copyright (C) 2015 CNRS
+ * Copyright (C) 2015, 2016 CNRS
  *
  * StarPU is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -99,6 +99,8 @@ int dotest(struct starpu_disk_ops *ops, char *base)
 	fclose(f);
 
 	int descriptor = open(path_file_start, O_RDWR);
+	if (descriptor < 0)
+		goto enoent2;
 #ifdef STARPU_HAVE_WINDOWS
 	_commit(descriptor);
 #else