Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Change unsigned to explicit type #49

Closed
wants to merge 2 commits into from

3 participants

@dogbert2

These patches change 'unsigned ' to 'unsigned int ' in
declarations and casts. In C, unsigned and unsigned int are the same by
definition, but the bulk of the code is of type 'unsigned int ' it
should be consistent.

@dogbert2 dogbert2 Change unsigned to explicit type
These patches change 'unsigned <foo>' to 'unsigned int <foo>' in
declarations and casts.  In C, unsigned and unsigned int are the same by
definition, but the bulk of the code is of type 'unsigned int <foo>' it
should be consistent.
38fae72
@binf
Collaborator

Seem's fair enough, just for info (already told Bill about it on irc), none of that code is even used but mabey firnsy can cherry pick that in my commit for 313?

@dogbert2 dogbert2 Add code to check return value from unlink()
This patch adds a check to the unlink() call made in util.c, which is
not currently done.  If the return value isn't zero, an error in
unlinking or removing the file has occurred.  This new code adds the
proper check, though I don't know if you want to add a different return
value in case unlink() fails.
992c80e
@firnsy
Owner

@dogbert2 - @binf is right here in that we will be attempting to remove the functions you've updated in dogbert2/barnyard2@38fae72.

However, I'm happy to merge your fix in dogbert2/barnyard2@992c80e if you can rebase it on current master.

@firnsy
Owner

@dogbert2: thanks, manually merged the unlink checks in 08c67b1

@firnsy firnsy closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 8, 2012
  1. @dogbert2

    Change unsigned to explicit type

    dogbert2 authored
    These patches change 'unsigned <foo>' to 'unsigned int <foo>' in
    declarations and casts.  In C, unsigned and unsigned int are the same by
    definition, but the bulk of the code is of type 'unsigned int <foo>' it
    should be consistent.
Commits on Oct 10, 2012
  1. @dogbert2

    Add code to check return value from unlink()

    dogbert2 authored
    This patch adds a check to the unlink() call made in util.c, which is
    not currently done.  If the return value isn't zero, an error in
    unlinking or removing the file has occurred.  This new code adds the
    proper check, though I don't know if you want to add a different return
    value in case unlink() fails.
This page is out of date. Refresh to see the latest.
View
10 src/sfutil/sfhashfcn.h
@@ -55,9 +55,9 @@
typedef struct _SFHASHFCN {
- unsigned seed;
- unsigned scale;
- unsigned hardener;
+ unsigned int seed;
+ unsigned int scale;
+ unsigned int hardener;
unsigned (*hash_fcn)(struct _SFHASHFCN * p,
unsigned char *d,
int n );
@@ -70,10 +70,10 @@ SFHASHFCN * sfhashfcn_new( int nrows );
void sfhashfcn_free( SFHASHFCN * p );
void sfhashfcn_static( SFHASHFCN * p );
-unsigned sfhashfcn_hash( SFHASHFCN * p, unsigned char *d, int n );
+unsigned int sfhashfcn_hash( SFHASHFCN * p, unsigned char *d, int n );
int sfhashfcn_set_keyops( SFHASHFCN * p,
- unsigned (*hash_fcn)( SFHASHFCN * p,
+ unsigned int (*hash_fcn)( SFHASHFCN * p,
unsigned char *d,
int n),
int (*keycmp_fcn)( const void *s1,
View
8 src/sfutil/sfmemcap.c
@@ -39,7 +39,7 @@
/*
* Set max # bytes & init other variables.
*/
-void sfmemcap_init( MEMCAP * mc, unsigned nbytes )
+void sfmemcap_init( MEMCAP * mc, unsigned int nbytes )
{
mc->memcap = nbytes;
mc->memused= 0;
@@ -49,7 +49,7 @@ void sfmemcap_init( MEMCAP * mc, unsigned nbytes )
/*
* Create and Init a MEMCAP - use free to release it
*/
-MEMCAP * sfmemcap_new( unsigned nbytes )
+MEMCAP * sfmemcap_new( unsigned int nbytes )
{
MEMCAP * mc;
@@ -71,7 +71,7 @@ void sfmemcap_delete( MEMCAP * p )
/*
* Allocate some memory
*/
-void * sfmemcap_alloc( MEMCAP * mc, unsigned nbytes )
+void * sfmemcap_alloc( MEMCAP * mc, unsigned int nbytes )
{
long * data;
@@ -115,7 +115,7 @@ void sfmemcap_free( MEMCAP * mc, void * p )
q = (long*)p;
q--;
- mc->memused -= (unsigned)(*q);
+ mc->memused -= (unsigned int)(*q);
mc->nblocks--;
free(q);
View
10 src/sfutil/sfmemcap.h
@@ -27,16 +27,16 @@
typedef struct
{
- unsigned memused;
- unsigned memcap;
+ unsigned int memused;
+ unsigned int memcap;
int nblocks;
}MEMCAP;
-void sfmemcap_init(MEMCAP * mc, unsigned nbytes);
-MEMCAP * sfmemcap_new( unsigned nbytes );
+void sfmemcap_init(MEMCAP * mc, unsigned int nbytes);
+MEMCAP * sfmemcap_new( unsigned int nbytes );
void sfmemcap_delete( MEMCAP * mc );
-void * sfmemcap_alloc(MEMCAP * mc, unsigned nbytes);
+void * sfmemcap_alloc(MEMCAP * mc, unsigned int nbytes);
void sfmemcap_showmem(MEMCAP * mc );
void sfmemcap_free( MEMCAP * mc, void * memory);
char * sfmemcap_strdup(MEMCAP * mc, const char *str);
View
8 src/sfutil/sfprimetable.c
@@ -31,7 +31,7 @@
#include "sfprimetable.h"
/* 0-8K, increments=8 */
static
-unsigned prime_table0[1024]={
+unsigned int prime_table0[1024]={
3, /* 1 */
7, /* 9 */
17, /* 17 */
@@ -1059,7 +1059,7 @@ unsigned prime_table0[1024]={
};
/* 0-64K, increments=64 */
static
-unsigned prime_table1[]={
+unsigned int prime_table1[]={
1, /* 1 */
61, /* 65 */
127, /* 129 */
@@ -2087,7 +2087,7 @@ unsigned prime_table1[]={
};
/* 0-1M, increments=1024 */
static
-unsigned prime_table2[1024]={
+unsigned int prime_table2[1024]={
1021, /* 1024 */
2039, /* 2048 */
3067, /* 3072 */
@@ -3114,7 +3114,7 @@ unsigned prime_table2[1024]={
};
/* 0-128M, increments=102400 */
static
-unsigned prime_table3[1024]={
+unsigned int prime_table3[1024]={
131071, /* 131072 */
262139, /* 262144 */
393209, /* 393216 */
View
36 src/sfutil/sfxhash.c
@@ -119,7 +119,7 @@ void s_free( SFXHASH * t, void * p )
/*
* User access to the memory management, do they need it ? WaitAndSee
*/
-void * sfxhash_alloc( SFXHASH * t, unsigned nbytes )
+void * sfxhash_alloc( SFXHASH * t, unsigned int nbytes )
{
return s_alloc( t, nbytes );
}
@@ -130,7 +130,7 @@ void sfxhash_free( SFXHASH * t, void * p )
int sfxhash_nearest_powerof2(int nrows)
{
- unsigned i;
+ unsigned int i;
nrows -= 1;
for(i=1; i<sizeof(nrows) * 8; i <<= 1)
@@ -324,7 +324,7 @@ void sfxhash_delete_free_list(SFXHASH *t)
*/
void sfxhash_delete( SFXHASH * h )
{
- unsigned i;
+ unsigned int i;
SFXHASH_NODE * node, * onode;
if( !h ) return;
@@ -367,7 +367,7 @@ int sfxhash_make_empty(SFXHASH *h)
{
SFXHASH_NODE *n = NULL;
SFXHASH_NODE *tmp = NULL;
- unsigned i;
+ unsigned int i;
if (h == NULL)
return -1;
@@ -405,7 +405,7 @@ int sfxhash_make_empty(SFXHASH *h)
* @param t SFXHASH table pointer
*
*/
-unsigned sfxhash_count( SFXHASH * t )
+unsigned int sfxhash_count( SFXHASH * t )
{
return t->count;
}
@@ -416,7 +416,7 @@ unsigned sfxhash_count( SFXHASH * t )
* @param t SFXHASH table pointer
*
*/
-unsigned sfxhash_anr_count( SFXHASH * t )
+unsigned int sfxhash_anr_count( SFXHASH * t )
{
return t->anr_count;
}
@@ -427,7 +427,7 @@ unsigned sfxhash_anr_count( SFXHASH * t )
* @param t SFXHASH table pointer
*
*/
-unsigned sfxhash_find_total( SFXHASH * t )
+unsigned int sfxhash_find_total( SFXHASH * t )
{
return t->find_success + t->find_fail;
}
@@ -438,7 +438,7 @@ unsigned sfxhash_find_total( SFXHASH * t )
* @param t SFXHASH table pointer
*
*/
-unsigned sfxhash_find_fail( SFXHASH * t )
+unsigned int sfxhash_find_fail( SFXHASH * t )
{
return t->find_fail;
}
@@ -449,7 +449,7 @@ unsigned sfxhash_find_fail( SFXHASH * t )
* @param t SFXHASH table pointer
*
*/
-unsigned sfxhash_find_success( SFXHASH * t )
+unsigned int sfxhash_find_success( SFXHASH * t )
{
return t->find_success;
}
@@ -463,7 +463,7 @@ unsigned sfxhash_find_success( SFXHASH * t )
* @param t SFXHASH table pointer
*
*/
-unsigned sfxhash_overhead_bytes( SFXHASH * t )
+unsigned int sfxhash_overhead_bytes( SFXHASH * t )
{
return t->overhead_bytes;
}
@@ -474,7 +474,7 @@ unsigned sfxhash_overhead_bytes( SFXHASH * t )
* @param t SFXHASH table pointer
*
*/
-unsigned sfxhash_overhead_blocks( SFXHASH * t )
+unsigned int sfxhash_overhead_blocks( SFXHASH * t )
{
return t->overhead_blocks;
}
@@ -712,7 +712,7 @@ SFXHASH_NODE * sfxhash_newnode( SFXHASH * t )
static
SFXHASH_NODE * sfxhash_find_node_row( SFXHASH * t, void * key, int * rindex )
{
- unsigned hashkey;
+ unsigned int hashkey;
int index;
SFXHASH_NODE *hnode;
@@ -1070,16 +1070,16 @@ SFXHASH_NODE * sfxhash_lru_node( SFXHASH * t )
* @return max depth of the table
*
*/
-unsigned sfxhash_maxdepth( SFXHASH * t )
+unsigned int sfxhash_maxdepth( SFXHASH * t )
{
- unsigned i;
- unsigned max_depth = 0;
+ unsigned int i;
+ unsigned int max_depth = 0;
SFXHASH_NODE * hnode;
for( i=0; i<t->nrows; i++ )
{
- unsigned cur_depth = 0;
+ unsigned int cur_depth = 0;
for(hnode = t->table[i]; hnode != NULL; hnode = hnode->next)
{
@@ -1134,7 +1134,7 @@ int sfxhash_free_node( SFXHASH * t, SFXHASH_NODE * hnode)
int sfxhash_remove( SFXHASH * t, void * key)
{
SFXHASH_NODE * hnode;
- unsigned hashkey, index;
+ unsigned int hashkey, index;
hashkey = t->sfhashfcn->hash_fcn( t->sfhashfcn,
(unsigned char*)key,
@@ -1253,7 +1253,7 @@ SFXHASH_NODE * sfxhash_findnext( SFXHASH * t )
*/
int sfxhash_set_keyops( SFXHASH *h ,
- unsigned (*hash_fcn)( SFHASHFCN * p,
+ unsigned int (*hash_fcn)( SFHASHFCN * p,
unsigned char *d,
int n),
int (*keycmp_fcn)( const void *s1,
View
40 src/sfutil/sfxhash.h
@@ -71,19 +71,19 @@ typedef struct _sfxhash
int keysize; /// bytes in key, if <= 0 -> keys are strings
int datasize; /// bytes in key, if == 0 -> user data
SFXHASH_NODE ** table; /// array of node ptr's */
- unsigned nrows; /// # rows int the hash table use a prime number 211, 9871
- unsigned count; /// total # nodes in table
+ unsigned int nrows; /// # rows int the hash table use a prime number 211, 9871
+ unsigned int count; /// total # nodes in table
- unsigned crow; /// findfirst/next row in table
+ unsigned int crow; /// findfirst/next row in table
SFXHASH_NODE * cnode; /// findfirst/next node ptr
int splay; /// whether to splay nodes with same hash bucket
- unsigned max_nodes; ///maximum # of nodes within a hash
+ unsigned int max_nodes; ///maximum # of nodes within a hash
MEMCAP mc;
- unsigned overhead_bytes; /// # of bytes that will be unavailable for nodes inside the table
- unsigned overhead_blocks; /// # of blocks consumed by the table
- unsigned find_fail;
- unsigned find_success;
+ unsigned int overhead_bytes; /// # of bytes that will be unavailable for nodes inside the table
+ unsigned int overhead_blocks; /// # of blocks consumed by the table
+ unsigned int find_fail;
+ unsigned int find_success;
SFXHASH_NODE * ghead, * gtail; /// global - root of all nodes allocated in table
@@ -92,8 +92,8 @@ typedef struct _sfxhash
/**Automatic Node Recover (ANR): When number of nodes in hash is equal to max_nodes, remove the least recently
* used nodes and use it for the new node. anr_tries indicates # of ANR tries.*/
- unsigned anr_tries;
- unsigned anr_count; /// # ANR ops performaed
+ unsigned int anr_tries;
+ unsigned int anr_count; /// # ANR ops performaed
int anr_flag; /// 0=off, !0=on
int (*anrfree)( void * key, void * data );
@@ -119,8 +119,8 @@ int sfxhash_make_empty(SFXHASH *);
int sfxhash_add ( SFXHASH * h, void * key, void * data );
SFXHASH_NODE * sfxhash_get_node( SFXHASH * t, void * key );
int sfxhash_remove( SFXHASH * h, void * key );
-unsigned sfxhash_count( SFXHASH * h );
-unsigned sfxhash_anr_count( SFXHASH * h );
+unsigned int sfxhash_count( SFXHASH * h );
+unsigned int sfxhash_anr_count( SFXHASH * h );
void * sfxhash_mru( SFXHASH * t );
void * sfxhash_lru( SFXHASH * t );
@@ -139,20 +139,20 @@ void sfxhash_gmovetofront( SFXHASH *t, SFXHASH_NODE * hnode );
void sfxhash_splaymode( SFXHASH * h, int mode );
-void * sfxhash_alloc( SFXHASH * t, unsigned nbytes );
+void * sfxhash_alloc( SFXHASH * t, unsigned int nbytes );
void sfxhash_free( SFXHASH * t, void * p );
int sfxhash_free_node(SFXHASH *t, SFXHASH_NODE *node);
-unsigned sfxhash_maxdepth( SFXHASH * t );
-unsigned sfxhash_overhead_bytes( SFXHASH * t );
-unsigned sfxhash_overhead_blocks( SFXHASH * t );
-unsigned sfxhash_find_success( SFXHASH * h );
-unsigned sfxhash_find_fail( SFXHASH * h );
-unsigned sfxhash_find_total( SFXHASH * h );
+unsigned int sfxhash_maxdepth( SFXHASH * t );
+unsigned int sfxhash_overhead_bytes( SFXHASH * t );
+unsigned int sfxhash_overhead_blocks( SFXHASH * t );
+unsigned int sfxhash_find_success( SFXHASH * h );
+unsigned int sfxhash_find_fail( SFXHASH * h );
+unsigned int sfxhash_find_total( SFXHASH * h );
int sfxhash_set_keyops( SFXHASH *h ,
- unsigned (*hash_fcn)( SFHASHFCN * p,
+ unsigned int(*hash_fcn)( SFHASHFCN * p,
unsigned char *d,
int n),
int (*keycmp_fcn)( const void *s1,
View
5 src/util.c
@@ -1795,7 +1795,10 @@ int Move(const char *source, const char *dest)
}
else
{
- unlink(source);
+ if (unlink(source) != 0) { /* oops, unlink/remove has failed */
+ LogMessage("Failed to unlink \"%s\": %s",
+ source, strerror(errno));
+ }
}
return 0;
}
Something went wrong with that request. Please try again.