summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Baumann <abaumann@yahoo.com>2012-05-01 10:43:03 +0200
committerAndreas Baumann <abaumann@yahoo.com>2012-05-01 10:43:03 +0200
commit0db336fe4665d3ca2e7b0f6c4fa44a32bf5aafd3 (patch)
tree8e8729d0d2d386743c7e8cf1b9e9a3d854689bf2
parentd04a9d1fe99eb0e1661cf7f2169b3f7dd0792efc (diff)
downloadpgfuse-0db336fe4665d3ca2e7b0f6c4fa44a32bf5aafd3.tar.gz
pgfuse-0db336fe4665d3ca2e7b0f6c4fa44a32bf5aafd3.tar.bz2
removed a lot of casts around off_t and size_t
-rw-r--r--pgfuse.c16
-rw-r--r--pgsql.c56
-rw-r--r--pgsql.h2
3 files changed, 37 insertions, 37 deletions
diff --git a/pgfuse.c b/pgfuse.c
index 51c821a..0126690 100644
--- a/pgfuse.c
+++ b/pgfuse.c
@@ -741,8 +741,8 @@ static int pgfuse_write( const char *path, const char *buf, size_t size,
PGconn *conn;
if( data->verbose ) {
- syslog( LOG_INFO, "Write to '%s' from offset %d, size %d on '%s', thread #%u",
- path, (unsigned int)offset, (unsigned int)size, data->mountpoint,
+ syslog( LOG_INFO, "Write to '%s' from offset %jd, size %zu on '%s', thread #%u",
+ path, offset, size, data->mountpoint,
THREAD_ID );
}
@@ -800,8 +800,8 @@ static int pgfuse_read( const char *path, char *buf, size_t size,
PGconn *conn;
if( data->verbose ) {
- syslog( LOG_INFO, "Read to '%s' from offset %d, size %d on '%s', thread #%u",
- path, (unsigned int)offset, (unsigned int)size, data->mountpoint,
+ syslog( LOG_INFO, "Read to '%s' from offset %jd, size %zu on '%s', thread #%u",
+ path, offset, size, data->mountpoint,
THREAD_ID );
}
@@ -833,8 +833,8 @@ static int pgfuse_truncate( const char* path, off_t offset )
PGconn *conn;
if( data->verbose ) {
- syslog( LOG_INFO, "Truncate of '%s' to size '%d' on '%s', thread #%u",
- path, (unsigned int)offset, data->mountpoint, THREAD_ID );
+ syslog( LOG_INFO, "Truncate of '%s' to size '%jd' on '%s', thread #%u",
+ path, offset, data->mountpoint, THREAD_ID );
}
ACQUIRE( conn );
@@ -888,8 +888,8 @@ static int pgfuse_ftruncate( const char *path, off_t offset, struct fuse_file_in
PGconn *conn;
if( data->verbose ) {
- syslog( LOG_INFO, "Truncate of '%s' to size '%d' on '%s', thread #%u",
- path, (unsigned int)offset, data->mountpoint,
+ syslog( LOG_INFO, "Truncate of '%s' to size '%jd' on '%s', thread #%u",
+ path, offset, data->mountpoint,
THREAD_ID );
}
diff --git a/pgsql.c b/pgsql.c
index 08d6c1f..5b7ff58 100644
--- a/pgsql.c
+++ b/pgsql.c
@@ -312,11 +312,11 @@ int psql_read_buf( PGconn *conn, const int64_t id, const char *path, char *buf,
int binary[3] = { 1, 1, 1 };
PGresult *res;
char zero_block[STANDARD_BLOCK_SIZE];
- int block_no;
+ int64_t block_no;
char *iptr;
char *data;
size_t copied;
- int db_block_no = 0;
+ int64_t db_block_no = 0;
int idx;
char *dst;
PgMeta meta;
@@ -361,7 +361,7 @@ int psql_read_buf( PGconn *conn, const int64_t id, const char *path, char *buf,
/* handle sparse files */
if( idx < PQntuples( res ) ) {
iptr = PQgetvalue( res, idx, 0 );
- db_block_no = ntohl( *( (uint32_t *)iptr ) );
+ db_block_no = ntohl( *( (int64_t *)iptr ) );
if( block_no < db_block_no ) {
data = zero_block;
@@ -396,16 +396,16 @@ int psql_read_buf( PGconn *conn, const int64_t id, const char *path, char *buf,
}
if( verbose ) {
- syslog( LOG_DEBUG, "File '%s', reading block '%d', copied: '%d', DB block: '%d'",
- path, block_no, (unsigned int)copied, db_block_no );
+ syslog( LOG_DEBUG, "File '%s', reading block '%"PRIi64"', copied: '%zu', DB block: '%"PRIi64"'",
+ path, block_no, copied, db_block_no );
}
}
PQclear( res );
if( copied != size ) {
- syslog( LOG_ERR, "File '%s', reading block '%d', copied '%d' bytes but expecting '%d'!",
- path, block_no, (unsigned int)copied, size );
+ syslog( LOG_ERR, "File '%s', reading block '%"PRIi64"', copied '%zu' bytes but expecting '%zu'!",
+ path, block_no, copied, size );
return -EIO;
}
@@ -579,39 +579,39 @@ update_again:
/* keep data on the right */
} else if( offset == 0 && len < STANDARD_BLOCK_SIZE ) {
- sprintf( sql, "UPDATE data set data = $3::bytea || substring( data from %u for %u ) WHERE dir_id=$1::bigint AND block_no=$2::bigint",
- len + 1, STANDARD_BLOCK_SIZE - (unsigned int)len );
+ sprintf( sql, "UPDATE data set data = $3::bytea || substring( data from %zu for %zu ) WHERE dir_id=$1::bigint AND block_no=$2::bigint",
+ len + 1, (size_t)STANDARD_BLOCK_SIZE - len );
/* keep data on the left */
} else if( offset > 0 && offset + len == STANDARD_BLOCK_SIZE ) {
- sprintf( sql, "UPDATE data set data = substring( data from %d for %d ) || $3::bytea WHERE dir_id=$1::bigint AND block_no=$2::bigint",
- 1, (unsigned int)offset );
+ sprintf( sql, "UPDATE data set data = substring( data from %d for %jd ) || $3::bytea WHERE dir_id=$1::bigint AND block_no=$2::bigint",
+ 1, offset );
/* small in the middle write, keep data on both sides */
} else if( offset > 0 && offset + len < STANDARD_BLOCK_SIZE ) {
- sprintf( sql, "UPDATE data set data = substring( data from %d for %d ) || $3::bytea || substring( data from %u for %u ) WHERE dir_id=$1::bigint AND block_no=$2::bigint",
- 1, (unsigned int)offset,
- (unsigned int)offset + (unsigned int)len + 1, STANDARD_BLOCK_SIZE - ( (unsigned int)offset + (unsigned int)len ) );
+ sprintf( sql, "UPDATE data set data = substring( data from %d for %jd ) || $3::bytea || substring( data from %jd for %jd ) WHERE dir_id=$1::bigint AND block_no=$2::bigint",
+ 1, offset,
+ offset + len + 1, STANDARD_BLOCK_SIZE - ( offset + len ) );
/* we should never get here */
} else {
- syslog( LOG_ERR, "Unhandled write case for file '%s' in block '%"PRIi64"': offset: %u, len: %u, blocksize: %u",
- path, block_no, (unsigned int)offset, (unsigned int)len, STANDARD_BLOCK_SIZE );
+ syslog( LOG_ERR, "Unhandled write case for file '%s' in block '%"PRIi64"': offset: %jd, len: %zu, blocksize: %u",
+ path, block_no, offset, len, STANDARD_BLOCK_SIZE );
return -EIO;
}
if( verbose ) {
- syslog( LOG_DEBUG, "%s, block: %"PRIi64", offset: %d, len: %d => %s\n",
- path, block_no, (unsigned int)offset, (unsigned int)len, sql );
+ syslog( LOG_DEBUG, "%s, block: %"PRIi64", offset: %jd, len: %zu => %s\n",
+ path, block_no, offset, len, sql );
}
res = PQexecParams( conn, sql, 3, NULL, values, lengths, binary, 1 );
if( PQresultStatus( res ) != PGRES_COMMAND_OK ) {
- syslog( LOG_ERR, "Error in psql_write_block(%"PRIi64",%u,%u) for file '%s' (%s): %s",
- block_no, (unsigned int)offset, (unsigned int)len, path,
+ syslog( LOG_ERR, "Error in psql_write_block(%"PRIi64",%jd,%zu) for file '%s' (%s): %s",
+ block_no, offset, len, path,
sql, PQerrorMessage( conn ) );
PQclear( res );
return -EIO;
@@ -639,8 +639,8 @@ update_again:
2, NULL, values, lengths, binary, 1 );
if( PQresultStatus( res ) != PGRES_COMMAND_OK ) {
- syslog( LOG_ERR, "Error in psql_write_block(%"PRIi64",%u,%u) for file '%s' allocating new block '%"PRIi64"': %s",
- block_no, (unsigned int)offset, (unsigned int)len, path, block_no, PQerrorMessage( conn ) );
+ syslog( LOG_ERR, "Error in psql_write_block(%"PRIi64",%jd,%zu) for file '%s' allocating new block '%"PRIi64"': %s",
+ block_no, offset, len, path, block_no, PQerrorMessage( conn ) );
PQclear( res );
return -EIO;
}
@@ -673,8 +673,8 @@ int psql_write_buf( PGconn *conn, const int64_t id, const char *path, const char
return res;
}
if( res != info.from_len ) {
- syslog( LOG_ERR, "Partial write in file '%s' in first block '%"PRIi64"' (%u instead of %u octets)",
- path, info.from_block, res, (unsigned int)info.from_len );
+ syslog( LOG_ERR, "Partial write in file '%s' in first block '%"PRIi64"' (%u instead of %zu octets)",
+ path, info.from_block, res, info.from_len );
return -EIO;
}
@@ -705,8 +705,8 @@ int psql_write_buf( PGconn *conn, const int64_t id, const char *path, const char
return res;
}
if( res != info.to_len ) {
- syslog( LOG_ERR, "Partial write in file '%s' in last block '%"PRIi64"' (%u instead of %u octets)",
- path, block_no, res, (unsigned int)info.to_len );
+ syslog( LOG_ERR, "Partial write in file '%s' in last block '%"PRIi64"' (%u instead of %zu octets)",
+ path, block_no, res, info.to_len );
return -EIO;
}
@@ -739,8 +739,8 @@ int psql_truncate( PGconn *conn, const int64_t id, const char *path, const off_t
2, NULL, values, lengths, binary, 1 );
if( PQresultStatus( dbres ) != PGRES_COMMAND_OK ) {
- syslog( LOG_ERR, "Error in psql_truncate for file '%s' to size '%u': %s",
- path, (unsigned int)offset, PQerrorMessage( conn ) );
+ syslog( LOG_ERR, "Error in psql_truncate for file '%s' to size '%jd': %s",
+ path, offset, PQerrorMessage( conn ) );
PQclear( dbres );
return -EIO;
}
diff --git a/pgsql.h b/pgsql.h
index 39c6ca7..1325be8 100644
--- a/pgsql.h
+++ b/pgsql.h
@@ -37,7 +37,7 @@ typedef struct PgMeta {
struct timespec ctime; /* last status change time */
struct timespec mtime; /* last modification time */
struct timespec atime; /* last access time */
- int parent_id; /* id/inode_no of parenting directory */
+ int64_t parent_id; /* id/inode_no of parenting directory */
} PgMeta;
/* --- transaction management and policies --- */