@ -51,7 +51,7 @@ static int open_slot(struct cache_slot *slot)
if ( fstat ( slot - > cache_fd , & slot - > cache_st ) )
if ( fstat ( slot - > cache_fd , & slot - > cache_st ) )
return errno ;
return errno ;
slot - > bufsize = read ( slot - > cache_fd , slot - > buf , sizeof ( slot - > buf ) ) ;
slot - > bufsize = x read( slot - > cache_fd , slot - > buf , sizeof ( slot - > buf ) ) ;
if ( slot - > bufsize < 0 )
if ( slot - > bufsize < 0 )
return errno ;
return errno ;
@ -81,16 +81,16 @@ static int close_slot(struct cache_slot *slot)
/* Print the content of the active cache slot (but skip the key). */
/* Print the content of the active cache slot (but skip the key). */
static int print_slot ( struct cache_slot * slot )
static int print_slot ( struct cache_slot * slot )
{
{
ssize_t i , j = 0 ;
ssize_t i ;
i = lseek ( slot - > cache_fd , slot - > keylen + 1 , SEEK_SET ) ;
i = lseek ( slot - > cache_fd , slot - > keylen + 1 , SEEK_SET ) ;
if ( i ! = slot - > keylen + 1 )
if ( i ! = slot - > keylen + 1 )
return errno ;
return errno ;
while ( ( i = read ( slot - > cache_fd , slot - > buf , sizeof ( slot - > buf ) ) ) > 0 )
while ( ( i = x read( slot - > cache_fd , slot - > buf , sizeof ( slot - > buf ) ) ) > 0 )
j = write ( STDOUT_FILENO , slot - > buf , i ) ;
i = x write( STDOUT_FILENO , slot - > buf , i ) ;
if ( j < 0 )
if ( i < 0 )
return errno ;
return errno ;
else
else
return 0 ;
return 0 ;
@ -142,7 +142,7 @@ static int lock_slot(struct cache_slot *slot)
S_IRUSR | S_IWUSR ) ;
S_IRUSR | S_IWUSR ) ;
if ( slot - > lock_fd = = - 1 )
if ( slot - > lock_fd = = - 1 )
return errno ;
return errno ;
if ( write ( slot - > lock_fd , slot - > key , slot - > keylen + 1 ) < 0 )
if ( x write( slot - > lock_fd , slot - > key , slot - > keylen + 1 ) < 0 )
return errno ;
return errno ;
return 0 ;
return 0 ;
}
}