mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-18 13:54:36 -05:00
Fix warning from clang --analyze
This commit is contained in:
parent
5d706dc0dd
commit
c268c10f8b
4 changed files with 24 additions and 11 deletions
|
@ -47,7 +47,7 @@ MenuReturn menu( char **lines, char **input, char *prompt,
|
|||
/**
|
||||
* Allocator wrappers
|
||||
*/
|
||||
void* allocate( unsigned long bytes );
|
||||
void* allocate( unsigned long bytes ) __attribute__((malloc));
|
||||
void* allocate_clear( unsigned long bytes );
|
||||
void* reallocate( void *ptr, unsigned long bytes );
|
||||
|
||||
|
|
|
@ -221,7 +221,7 @@ static int sort_func ( const void *a, const void *b )
|
|||
}
|
||||
static char ** get_apps ( )
|
||||
{
|
||||
int num_favorites = 0;
|
||||
unsigned int num_favorites = 0;
|
||||
unsigned int index = 0;
|
||||
char *path;
|
||||
char **retv = NULL;
|
||||
|
@ -277,7 +277,7 @@ static char ** get_apps ( )
|
|||
|
||||
// This is a nice little penalty, but doable? time will tell.
|
||||
// given num_favorites is max 25.
|
||||
for ( int j = 0; found == 0 && j < num_favorites; j++ ) {
|
||||
for ( unsigned int j = 0; found == 0 && j < num_favorites; j++ ) {
|
||||
if ( strcasecmp( dent->d_name, retv[j] ) == 0 ) found = 1;
|
||||
}
|
||||
|
||||
|
@ -294,7 +294,9 @@ static char ** get_apps ( )
|
|||
}
|
||||
|
||||
// TODO: check this is still fast enough. (takes 1ms on laptop.)
|
||||
qsort( &retv[num_favorites],index-num_favorites, sizeof( char* ), sort_func );
|
||||
if(index > num_favorites) {
|
||||
qsort( &retv[num_favorites],index-num_favorites, sizeof( char* ), sort_func );
|
||||
}
|
||||
free( path );
|
||||
#ifdef TIMING
|
||||
clock_gettime( CLOCK_REALTIME, &stop );
|
||||
|
|
|
@ -340,12 +340,15 @@ winlist* winlist_new()
|
|||
l->data = allocate( sizeof( void* ) * ( WINLIST+1 ) );
|
||||
return l;
|
||||
}
|
||||
int winlist_append( winlist *l, Window w, void *d )
|
||||
int winlist_append( winlist *l , Window w, void *d )
|
||||
{
|
||||
if ( l->len > 0 && !( l->len % WINLIST ) ) {
|
||||
l->array = reallocate( l->array, sizeof( Window ) * ( l->len+WINLIST+1 ) );
|
||||
l->data = reallocate( l->data, sizeof( void* ) * ( l->len+WINLIST+1 ) );
|
||||
}
|
||||
// Make clang-check happy.
|
||||
// TODO: make clang-check clear this should never be 0.
|
||||
if(l->data == NULL || l->array == NULL) return 0;
|
||||
|
||||
l->data[l->len] = d;
|
||||
l->array[l->len++] = w;
|
||||
|
@ -503,10 +506,16 @@ char* window_get_text_prop( Window w, Atom atom )
|
|||
if ( XGetTextProperty( display, w, &prop, atom ) && prop.value && prop.nitems ) {
|
||||
if ( prop.encoding == XA_STRING ) {
|
||||
res = allocate( strlen( ( char* )prop.value )+1 );
|
||||
strcpy( res, ( char* )prop.value );
|
||||
// make clang-check happy.
|
||||
if(res) {
|
||||
strcpy( res, ( char* )prop.value );
|
||||
}
|
||||
} else if ( Xutf8TextPropertyToTextList( display, &prop, &list, &count ) >= Success && count > 0 && *list ) {
|
||||
res = allocate( strlen( *list )+1 );
|
||||
strcpy( res, *list );
|
||||
// make clang-check happy.
|
||||
if(res) {
|
||||
strcpy( res, *list );
|
||||
}
|
||||
XFreeStringList( list );
|
||||
}
|
||||
}
|
||||
|
@ -732,7 +741,7 @@ static int calculate_common_prefix( char **filtered, int max_lines )
|
|||
{
|
||||
int length_prefix = 0;
|
||||
|
||||
if ( filtered[0] != NULL ) {
|
||||
if ( filtered && filtered[0] != NULL ) {
|
||||
int found = 1;
|
||||
char *p = filtered[0];
|
||||
|
||||
|
|
|
@ -193,7 +193,7 @@ static int sort_func ( const void *a, const void *b )
|
|||
}
|
||||
static char ** get_ssh ( )
|
||||
{
|
||||
int num_favorites = 0;
|
||||
unsigned int num_favorites = 0;
|
||||
unsigned int index = 0;
|
||||
char *path;
|
||||
char **retv = NULL;
|
||||
|
@ -246,7 +246,7 @@ static char ** get_ssh ( )
|
|||
|
||||
// This is a nice little penalty, but doable? time will tell.
|
||||
// given num_favorites is max 25.
|
||||
for ( int j = 0; found == 0 && j < num_favorites; j++ ) {
|
||||
for ( unsigned int j = 0; found == 0 && j < num_favorites; j++ ) {
|
||||
if ( strncasecmp( &buffer[start], retv[j],stop-start ) == 0 ) found = 1;
|
||||
}
|
||||
|
||||
|
@ -263,7 +263,9 @@ static char ** get_ssh ( )
|
|||
}
|
||||
|
||||
// TODO: check this is still fast enough. (takes 1ms on laptop.)
|
||||
qsort( &retv[num_favorites],index-num_favorites, sizeof( char* ), sort_func );
|
||||
if(index > num_favorites) {
|
||||
qsort( &retv[num_favorites],index-num_favorites, sizeof( char* ), sort_func );
|
||||
}
|
||||
free( path );
|
||||
#ifdef TIMING
|
||||
clock_gettime( CLOCK_REALTIME, &stop );
|
||||
|
|
Loading…
Reference in a new issue