smalloc: pool->file is only used in add_pool(), so make it local
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
diff --git a/smalloc.c b/smalloc.c
index fc6ac52..1e72068 100644
--- a/smalloc.c
+++ b/smalloc.c
@@ -37,7 +37,6 @@
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 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 @@
* 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 @@
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;
}