Removes some conversion warnings.

This commit is contained in:
Andrea Mazzoleni 2011-03-30 17:13:42 +02:00
parent bd80df19ac
commit a5aa964f8f
5 changed files with 10 additions and 40 deletions

7
elem.h
View file

@ -30,7 +30,7 @@
/**
* Invalid position.
*/
#define POS_INVALID -1
#define POS_INVALID ((block_off_t)-1)
/**
* Basic block position type.
@ -40,8 +40,9 @@ typedef uint32_t block_off_t;
/**
* Basic data position type.
* It's signed as file size and offset are usually signed.
*/
typedef uint64_t data_off_t;
typedef int64_t data_off_t;
/**
* Filter for paths.
@ -76,7 +77,7 @@ struct snapraid_file {
data_off_t size; /**< Size of the file. */
struct snapraid_block* blockvec; /**< All the blocks of the file. */
block_off_t blockmax; /**< Number of blocks. */
uint64_t mtime; /**< Modification time. */
int64_t mtime; /**< Modification time. */
uint64_t inode; /**< Inode. */
int is_present; /**< If it's seen as present. */
int is_filtered; /**< If it's filtered out. */

View file

@ -251,7 +251,7 @@ int handle_read(struct snapraid_handle* handle, struct snapraid_block* block, un
read_ret = read(handle->f, block_buffer, read_size);
#endif
if (read_ret != read_size) {
if (read_ret != (ssize_t)read_size) { /* conversion is safe because block_size is always small */
fprintf(stderr, "Error reading file '%s'. %s.\n", handle->path, strerror(errno));
return -1;
}
@ -284,7 +284,7 @@ int handle_write(struct snapraid_handle* handle, struct snapraid_block* block, u
write_ret = write(handle->f, block_buffer, write_size);
#endif
if (write_ret != write_size) {
if (write_ret != (ssize_t)write_size) { /* conversion is safe because block_size is always small */
fprintf(stderr, "Error writing file '%s'. %s.\n", handle->path, strerror(errno));
return -1;
}
@ -295,28 +295,4 @@ int handle_write(struct snapraid_handle* handle, struct snapraid_block* block, u
return 0;
}
int handle_readahead(struct snapraid_handle* handle, struct snapraid_block* block, unsigned block_size)
{
#if HAVE_POSIX_FADVISE
data_off_t offset;
unsigned read_size;
int ret;
/* do nothing if the file is different */
if (handle->file != block->file)
return 0;
offset = block_file_pos(block) * (data_off_t)block_size;
read_size = block_file_size(block, block_size);
/* advise access of the next block */
ret = posix_fadvise(handle->f, offset, read_size, POSIX_FADV_WILLNEED);
if (ret != 0) {
fprintf(stderr, "Error advising file '%s'. %s.\n", handle->path, strerror(errno));
return -1;
}
#endif
return 0;
}

View file

@ -61,12 +61,5 @@ int handle_read(struct snapraid_handle* handle, struct snapraid_block* block, un
*/
int handle_write(struct snapraid_handle* handle, struct snapraid_block* block, unsigned char* block_buffer, unsigned block_size);
/**
* Readahead optimization where available.
* \note
* It doesn't seem to give any speed improvement over posix_fadvise(POSIX_FADV_SEQUENTIAL).
*/
int handle_readahead(struct snapraid_handle* handle, struct snapraid_block* block, unsigned block_size);
#endif

View file

@ -193,7 +193,7 @@ int parity_write(const char* path, int f, block_off_t pos, unsigned char* block_
write_ret = write(f, block_buffer, block_size);
#endif
if (write_ret != block_size) {
if (write_ret != (ssize_t)block_size) { /* conversion is safe because block_size is always small */
if (errno == ENOSPC) {
fprintf(stderr, "Failed to grow parity file '%s' due lack of space.\n", path);
} else {
@ -225,7 +225,7 @@ int parity_read(const char* path, int f, block_off_t pos, unsigned char* block_b
read_ret = read(f, block_buffer, block_size);
#endif
if (read_ret != block_size) {
if (read_ret != (ssize_t)block_size) { /* conversion is safe because block_size is always small */
fprintf(stderr, "Error reading file '%s'. %s.\n", path, strerror(errno));
return -1;
}

View file

@ -129,8 +129,8 @@
*/
struct windows_stat {
uint64_t st_ino;
uint64_t st_size;
uint64_t st_mtime;
int64_t st_size;
int64_t st_mtime;
uint32_t st_mode;
};