From: Jens Axboe Date: Thu, 4 Dec 2008 13:33:41 +0000 (+0100) Subject: smalloc: pool->file is only used in add_pool(), so make it local X-Git-Tag: fio-1.24~37 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=b8a6582e89999f88c574b905b89743762d8080df;hp=443bb114d963a99082eef916025268a5a107092b smalloc: pool->file is only used in add_pool(), so make it local Signed-off-by: Jens Axboe --- diff --git a/smalloc.c b/smalloc.c index fc6ac526..1e720685 100644 --- a/smalloc.c +++ b/smalloc.c @@ -37,7 +37,6 @@ struct pool { unsigned int nr_blocks; /* total blocks */ unsigned int next_non_full; int fd; /* memory backing fd */ - char file[PATH_MAX]; /* filename for fd */ unsigned int mmap_size; }; @@ -183,11 +182,11 @@ static int find_next_zero(int word, int start) static int add_pool(struct pool *pool, unsigned int alloc_size) { - void *ptr; int fd, bitmap_blocks; + char file[] = "/tmp/.fio_smalloc.XXXXXX"; + void *ptr; - strcpy(pool->file, "/tmp/.fio_smalloc.XXXXXX"); - fd = mkstemp(pool->file); + fd = mkstemp(file); if (fd < 0) goto out_close; @@ -229,8 +228,8 @@ static int add_pool(struct pool *pool, unsigned int alloc_size) * which happens both for cleanup or unexpected quit. This way we * don't leave temp files around in case of a crash. */ + unlink(file); pool->fd = fd; - unlink(pool->file); nr_pools++; return 0; @@ -238,10 +237,9 @@ out_unlink: fprintf(stderr, "smalloc: failed adding pool\n"); if (pool->map) munmap(pool->map, pool->mmap_size); - unlink(pool->file); + unlink(file); out_close: - if (fd >= 0) - close(fd); + close(fd); return 1; }