From b8a6582e89999f88c574b905b89743762d8080df Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 4 Dec 2008 14:33:41 +0100 Subject: [PATCH] smalloc: pool->file is only used in add_pool(), so make it local Signed-off-by: Jens Axboe --- smalloc.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) 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; } -- 2.25.1