浏览代码

Avoid undefined behavior of 0-lengthed arrays

Samuel Thibault 9 年之前
父节点
当前提交
6315e8a7af
共有 1 个文件被更改,包括 8 次插入1 次删除
  1. 8 1
      examples/sched_ctx/parallel_code.c

+ 8 - 1
examples/sched_ctx/parallel_code.c

@@ -1,6 +1,6 @@
 /* StarPU --- Runtime system for heterogeneous multicore architectures.
  *
- * Copyright (C) 2010-2014  Université de Bordeaux
+ * Copyright (C) 2010-2014, 2016  Université de Bordeaux
  * Copyright (C) 2010-2015  CNRS
  *
  * StarPU is free software; you can redistribute it and/or modify
@@ -109,6 +109,13 @@ int main(int argc, char **argv)
 	procs2[0] = 0;
 #endif
 
+	if (nprocs1 < 4)
+	{
+		/* Not enough procs */
+		starpu_shutdown();
+		return 77;
+	}
+
 	/*create contexts however you want*/
 	unsigned sched_ctx1 = starpu_sched_ctx_create(procs1, nprocs1, "ctx1", STARPU_SCHED_CTX_POLICY_NAME, "dmda", 0);
 	unsigned sched_ctx2 = starpu_sched_ctx_create(procs2, nprocs2, "ctx2", STARPU_SCHED_CTX_POLICY_NAME, "dmda", 0);