sizeof on coffee_fd_set is no longer suitable since it has become a

pointer.
This commit is contained in:
nvt-se 2009-02-09 12:02:10 +00:00
parent f1fc4c879f
commit 98f7f9a06a

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2008, Swedish Institute of Computer Science * Copyright (c) 2008, 2009, Swedish Institute of Computer Science
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -69,9 +69,9 @@
#define INVALID_PAGE ((coffee_page_t)-1) #define INVALID_PAGE ((coffee_page_t)-1)
#define UNKNOWN_OFFSET ((coffee_offset_t)-1) #define UNKNOWN_OFFSET ((coffee_offset_t)-1)
#define FD_VALID(fd) \ #define FD_VALID(fd) \
((fd) >= 0 && (fd) < COFFEE_FD_SET_SIZE && \ ((fd) >= 0 && (fd) < COFFEE_FD_SET_SIZE && \
coffee_fd_set[(fd)].flags != COFFEE_FD_FREE) coffee_fd_set[(fd)].flags != COFFEE_FD_FREE)
#define FD_READABLE(fd) (coffee_fd_set[(fd)].flags & CFS_READ) #define FD_READABLE(fd) (coffee_fd_set[(fd)].flags & CFS_READ)
#define FD_WRITABLE(fd) (coffee_fd_set[(fd)].flags & CFS_WRITE) #define FD_WRITABLE(fd) (coffee_fd_set[(fd)].flags & CFS_WRITE)
#define FD_APPENDABLE(fd) (coffee_fd_set[(fd)].flags & CFS_APPEND) #define FD_APPENDABLE(fd) (coffee_fd_set[(fd)].flags & CFS_APPEND)
@ -79,7 +79,7 @@
#define FILE_MODIFIED(file) ((file)->flags & COFFEE_FILE_MODIFIED) #define FILE_MODIFIED(file) ((file)->flags & COFFEE_FILE_MODIFIED)
/* File header flags. */ /* File header flags. */
#define HDR_FLAG_VALID 0x1 /* Completely written header. */ #define HDR_FLAG_VALID 0x1 /* Completely written header. */
#define HDR_FLAG_ALLOCATED 0x2 /* Allocated file. */ #define HDR_FLAG_ALLOCATED 0x2 /* Allocated file. */
#define HDR_FLAG_OBSOLETE 0x4 /* File marked for GC. */ #define HDR_FLAG_OBSOLETE 0x4 /* File marked for GC. */
#define HDR_FLAG_MODIFIED 0x8 /* Modified file, log exists. */ #define HDR_FLAG_MODIFIED 0x8 /* Modified file, log exists. */
@ -93,11 +93,13 @@
#define HDR_ISOLATED(hdr) ((hdr).flags & HDR_FLAG_ISOLATED) #define HDR_ISOLATED(hdr) ((hdr).flags & HDR_FLAG_ISOLATED)
#define HDR_OBSOLETE(hdr) ((hdr).flags & HDR_FLAG_OBSOLETE) #define HDR_OBSOLETE(hdr) ((hdr).flags & HDR_FLAG_OBSOLETE)
#define HDR_ACTIVE(hdr) (HDR_ALLOCATED(hdr) && \ #define HDR_ACTIVE(hdr) (HDR_ALLOCATED(hdr) && \
!HDR_OBSOLETE(hdr) && \ !HDR_OBSOLETE(hdr) && \
!HDR_ISOLATED(hdr)) !HDR_ISOLATED(hdr))
#define COFFEE_PAGE_COUNT ((coffee_page_t)(COFFEE_SIZE / COFFEE_PAGE_SIZE)) #define COFFEE_PAGE_COUNT \
#define COFFEE_PAGES_PER_SECTOR ((coffee_page_t)(COFFEE_SECTOR_SIZE / COFFEE_PAGE_SIZE)) ((coffee_page_t)(COFFEE_SIZE / COFFEE_PAGE_SIZE))
#define COFFEE_PAGES_PER_SECTOR \
((coffee_page_t)(COFFEE_SECTOR_SIZE / COFFEE_PAGE_SIZE))
struct file { struct file {
coffee_offset_t end; coffee_offset_t end;
@ -1177,7 +1179,9 @@ cfs_coffee_format(void)
watchdog_start(); watchdog_start();
/* All file descriptors have become invalid. */ /* All file descriptors have become invalid. */
memset(&coffee_fd_set, 0, sizeof(coffee_fd_set)); for(i = 0; i < COFFEE_FD_SET_SIZE; i++) {
coffee_fd_set[i].flags = COFFEE_FD_FREE;
}
PRINTF("done!\n"); PRINTF("done!\n");