Skip to content

Commit

Permalink
Two minor code optimizations
Browse files Browse the repository at this point in the history
1. Use unsigned suffix in "print_flags" as shifting a signed integer 31 bits to the left may result in undefined behavior otherwise. This is uncritical as we have only 28 possible flags that can be set at the moment.
2. Prototype of logg was slightly different from actual definition in log.c. This had no effect

Signed-off-by: DL6ER <dl6er@dl6er.de>
  • Loading branch information
DL6ER committed Oct 27, 2018
1 parent 6880fbd commit 560bca5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dnsmasq_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ void print_flags(unsigned int flags)
unsigned int i;
char *flagstr = calloc(256,sizeof(char));
for(i = 0; i < sizeof(flags)*8; i++)
if(flags & (1 << i))
if(flags & (1u << i))
strcat(flagstr, flagnames[i]);
logg(" Flags: %s", flagstr);
free(flagstr);
Expand Down
2 changes: 1 addition & 1 deletion routines.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ char * getUserName(void);
void removepid(void);

void open_FTL_log(bool test);
void logg(const char* str, ...);
void logg(const char* format, ...);
void logg_struct_resize(const char* str, int to, int step);
void log_counter_info(void);
void format_memory_size(char *prefix, unsigned long int bytes, double *formated);
Expand Down

0 comments on commit 560bca5

Please sign in to comment.