[PATCH] Add unconditional exit to allocate again

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Readd unconditional exit on error to bitmask_alloc because all the 
callers cannot deal with failure currently

Index: numactl-2.0.0/libnuma.c
===================================================================
--- numactl-2.0.0.orig/libnuma.c
+++ numactl-2.0.0/libnuma.c
@@ -182,6 +182,8 @@ numa_bitmask_nbytes(struct bitmask *bmp)
 }
 
 /* where n is the number of bits in the map */
+/* This function should not exit on failure, but right now we cannot really
+   recover from this. */
 struct bitmask *
 numa_bitmask_alloc(unsigned int n)
 {
@@ -189,18 +191,22 @@ numa_bitmask_alloc(unsigned int n)
 
 	if (n < 1) {
 		numa_error("request to allocate mask for invalid number; abort\n");
-		return NULL;
+		exit(1);
 	}
 	bmp = malloc(sizeof(*bmp));
 	if (bmp == 0)
-		return 0;
+		goto oom;
 	bmp->size = n;
 	bmp->maskp = calloc(longsperbits(n), sizeof(unsigned long));
 	if (bmp->maskp == 0) {
 		free(bmp);
-		return 0;
+		goto oom;
 	}
 	return bmp;
+
+oom:
+	numa_error("Out of memory allocating bitmask");
+	exit(1);
 }
 
 void
--
To unsubscribe from this list: send the line "unsubscribe linux-numa" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]     [Devices]

  Powered by Linux