Skip to content

Commit

Permalink
Updating C code so to remove blocks leading to compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Roach committed Nov 21, 2020
1 parent e9586e2 commit c8a07f1
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 16 deletions.
3 changes: 2 additions & 1 deletion src/poaV2/align_lpo2.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,8 @@ LPOScore_T align_lpo (LPOSequence_T *lposeq_x,
}
}

IF_GUARD(best_x>=len_x || best_y>=len_y,1.1,(ERRTXT,"Bounds exceeded!\nbest_x,best_y:%d,%d\tlen:%d,%d\n",best_x,best_y,len_x,len_y),CRASH);
IF_GUARD(best_x>=len_x || best_y>=len_y,1.1,(ERRTXT,"Bounds exceeded!\nbest_x,best_y:%d,%d\tlen:%d,%d\n",best_x,best_y,len_x,len_y),CRASH)
;

/*
fprintf (stderr, "aligned (%d nodes, %ld edges) to (%d nodes)\n", len_x, n_edges/len_y, len_y);
Expand Down
3 changes: 2 additions & 1 deletion src/poaV2/align_lpo_po2.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,8 @@ LPOScore_T align_lpo_po (LPOSequence_T *lposeq_x,
}
}

IF_GUARD(best_x>=len_x || best_y>=len_y,1.1,(ERRTXT,"Bounds exceeded!\nbest_x,best_y:%d,%d\tlen:%d,%d\n",best_x,best_y,len_x,len_y),CRASH);
IF_GUARD(best_x>=len_x || best_y>=len_y,1.1,(ERRTXT,"Bounds exceeded!\nbest_x,best_y:%d,%d\tlen:%d,%d\n",best_x,best_y,len_x,len_y),CRASH)
;

/*
fprintf (stderr, "aligned (%d nodes, %ld edges) to (%d nodes, %ld edges): ", len_x, n_edges_x, len_y, n_edges_y);
Expand Down
15 changes: 9 additions & 6 deletions src/poaV2/buildup_lpo.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ LPOSequence_T *buildup_lpo(LPOSequence_T *new_seq,
int use_aggressive_fusion,
int use_global_alignment)
{
int i,max_alloc=0,total_alloc;
int i,total_alloc;
unsigned long max_alloc=0;
LPOLetterRef_T *al1=NULL,*al2=NULL;

lpo_index_symbols(new_seq,score_matrix); /* MAKE SURE LPO IS TRANSLATED */
Expand All @@ -106,7 +107,7 @@ LPOSequence_T *buildup_lpo(LPOSequence_T *new_seq,
if (total_alloc>max_alloc) { /* DP RECTANGLE ARRAY SIZE */
max_alloc=total_alloc;
if (max_alloc>POA_MAX_ALLOC) {
WARN_MSG(TRAP,(ERRTXT,"Exceeded memory bound: %d\n Exiting!\n\n",max_alloc),"$Revision: 1.2.2.9 $");
WARN_MSG(TRAP,(ERRTXT,"Exceeded memory bound: %lu\n Exiting!\n\n",max_alloc),"$Revision: 1.2.2.9 $");
break; /* JUST RETURN AND FINISH */
}
}
Expand Down Expand Up @@ -209,7 +210,8 @@ LPOSequence_T *buildup_clipped_lpo(LPOSequence_T *new_seq,
int use_global_alignment)
{
int i,ntemp,offset=0,nidentity,length_max=0,match_length=0;
int total_alloc,max_alloc=0;
int total_alloc;
unsigned long max_alloc=0;
LPOLetterRef_T *al1=NULL,*al2=NULL;
LPOLetter_T *temp;
float identity_max=0.,f;
Expand All @@ -223,7 +225,7 @@ LPOSequence_T *buildup_clipped_lpo(LPOSequence_T *new_seq,
if (total_alloc>max_alloc) { /* DP RECTANGLE ARRAY SIZE */
max_alloc=total_alloc;
if (max_alloc>POA_MAX_ALLOC) {
WARN_MSG(TRAP,(ERRTXT,"Exceeded memory bound: %d\n Exiting!\n\n",max_alloc),"$Revision: 1.2.2.9 $");
WARN_MSG(TRAP,(ERRTXT,"Exceeded memory bound: %lu\n Exiting!\n\n",max_alloc),"$Revision: 1.2.2.9 $");
break; /* JUST RETURN AND FINISH */
}
}
Expand Down Expand Up @@ -403,7 +405,8 @@ LPOSequence_T *buildup_progressive_lpo(int nseq,LPOSequence_T **all_seqs,
int use_global_alignment,
int preserve_sequence_order)
{
int i,j,k,max_alloc=0,total_alloc,min_counts=0;
int i,j,k,total_alloc,min_counts=0;
unsigned long max_alloc=0;
SeqPairScore_T *score=NULL;
LPOSequence_T *new_seq=NULL;
FILE *ifile=NULL;
Expand Down Expand Up @@ -479,7 +482,7 @@ LPOSequence_T *buildup_progressive_lpo(int nseq,LPOSequence_T **all_seqs,
if (total_alloc>max_alloc) { /* DP RECTANGLE ARRAY SIZE */
max_alloc=total_alloc;
if (max_alloc>POA_MAX_ALLOC) {
WARN_MSG(TRAP,(ERRTXT,"Exceeded memory bound: %d\n Exiting!\n\n",max_alloc),"$Revision: 1.2.2.9 $");
WARN_MSG(TRAP,(ERRTXT,"Exceeded memory bound: %lu\n Exiting!\n\n",max_alloc),"$Revision: 1.2.2.9 $");
break; /* JUST RETURN AND FINISH */
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/poaV2/default.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ int stringptr_free(stringptr *s);
else if (NULL == ((memptr)=(ATYPE *)calloc((size_t)(N),sizeof(ATYPE)))) { \
fprintf(stderr,"%s, line %d: *** out of memory \n",__FILE__,__LINE__); \
fprintf(stderr,"Unable to meet request: %s[%d]\n",STRINGIFY(memptr),(N)); \
fprintf(stderr,"requested %d x %d bytes \n",(N),sizeof(ATYPE)); \
fprintf(stderr,"requested %d x %lu bytes \n",(N),sizeof(ATYPE)); \
MALLOC_FAILURE_ACTION; \
}
#endif
Expand All @@ -259,7 +259,7 @@ int stringptr_free(stringptr *s);
else if (NULL == ((memptr)=(ATYPE *)calloc((size_t)(N),sizeof(ATYPE)))) { \
fprintf(stderr,"%s, line %d: *** out of memory \n",__FILE__,__LINE__); \
fprintf(stderr,"Unable to meet request: %s[%d]\n",STRINGIFY(memptr),(N)); \
fprintf(stderr,"requested %d x %d bytes \n",(N),sizeof(ATYPE)); \
fprintf(stderr,"requested %d x %lu bytes \n",(N),sizeof(ATYPE)); \
MALLOC_FAILURE_ACTION; \
}
#endif
Expand Down Expand Up @@ -295,7 +295,7 @@ int stringptr_free(stringptr *s);
__FILE__,__LINE__);*/ \
if ((NUM)<=0) { \
if (MEM0_REQUEST_BAD) {\
fprintf(stderr,"%s, line %d: *** invalid memory request: %s[%d].\n",\
fprintf(stderr,"%s, line %d: *** invalid memory request: %s[%lu].\n",\
__FILE__,__LINE__,STRINGIFY(memptr),(NUM)); \
REALLOC_FAILURE_ACTION; \
}\
Expand All @@ -307,7 +307,7 @@ int stringptr_free(stringptr *s);
else { \
fprintf(stderr,"%s, line %d: *** out of memory \n",__FILE__,__LINE__); \
fprintf(stderr,"Unable to meet request: %s\n",STRINGIFY(memptr)); \
fprintf(stderr,"requested %d x %d bytes \n",(NUM),sizeof(ATYPE)); \
fprintf(stderr,"requested %d x %lu bytes \n",(NUM),sizeof(ATYPE)); \
REALLOC_FAILURE_ACTION; \
} \
}
Expand All @@ -332,7 +332,7 @@ int stringptr_free(stringptr *s);
else { \
fprintf(stderr,"%s, line %d: *** out of memory \n",__FILE__,__LINE__); \
fprintf(stderr,"Unable to meet request: %s\n",STRINGIFY(memptr)); \
fprintf(stderr,"requested %d x %d bytes \n",(NUM),sizeof(ATYPE)); \
fprintf(stderr,"requested %d x %lu bytes \n",(NUM),sizeof(ATYPE)); \
REALLOC_FAILURE_ACTION; \
} \
}
Expand Down
3 changes: 2 additions & 1 deletion src/poaV2/lpo.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,8 @@ void reindex_lpo_source_seqs (LPOSequence_T *seq, int *perm)
}
for (i=0; i<nseq; i++) {
map[i] = perm[i];
IF_GUARD (map[i]>=nseq || map[i]<0 || invmap[map[i]]!=-1, 1.1, (ERRTXT,"Bad argument! 'perm' must be a permutation of [0,%d]\n",nseq-1), CRASH);
IF_GUARD (map[i]>=nseq || map[i]<0 || invmap[map[i]]!=-1, 1.1, (ERRTXT,"Bad argument! 'perm' must be a permutation of [0,%d]\n",nseq-1), CRASH)
;
invmap[map[i]] = i;
}

Expand Down
2 changes: 1 addition & 1 deletion src/poaV2/numeric_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ void read_numeric_data(int nsource_seq,
if (LOOP_FINISHED(i,nsource_seq)) /* SEQ NOT FOUND!! */
WARN_MSG(USERR,(ERRTXT,"Error! NUMERIC_DATA %s, sequence %s does not exist. Skipping.\n\n",data_name,seq_name),"$Revision: 1.2 $");
else { /* FOUND THE SEQ, SAVE THE DATA */
if (data=find_numeric_data(source_seq+i,data_name)) /*REUSE EXISTING*/
if ((data=find_numeric_data(source_seq+i,data_name))) /*REUSE EXISTING*/
WARN_MSG(WARN,(ERRTXT,"NUMERIC_DATA %s already exists on sequence %s. Overwriting.\n",data_name,seq_name),"$Revision: 1.2 $");
else /* CREATE A NEW DATA HOLDER */
data=new_numeric_data(source_seq+i,data_name,title,0.);
Expand Down
2 changes: 1 addition & 1 deletion src/poaV2/stringptr.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ char *stringptr_cat(stringptr *s1,const char s2[]) /* ~~g --- */

char *stringptr_cpy(stringptr *s1,const char s2[]) /* ~~g --- */
{
GETMEM(s1->p,strlen(s2)+1,s1->last_alloc,STRINGPTR_BUFFER_CHUNK,char);
GETMEM(s1->p,(int) strlen(s2)+1,s1->last_alloc,STRINGPTR_BUFFER_CHUNK,char);
strcpy(s1->p,s2);

return s1->p;
Expand Down

0 comments on commit c8a07f1

Please sign in to comment.