Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

splinted some more files

  • Loading branch information...
commit c0fc4d37390dc85b6154bddc264010ee33f32a23 1 parent 42a4eb1
@maoserr authored
View
4 CMakeLists.txt
@@ -260,11 +260,13 @@ if(SPLINT_PATH)
foreach(loop_var ${RSG_INCLUDES})
set(SPLINT_PARAMS ${SPLINT_PARAMS} -I${loop_var})
endforeach(loop_var ${RSG_INCLUDES})
+ set(SPLINT_PARAMS ${SPLINT_PARAMS}
+ -systemdirs "/usr/include:/usr/include/sys")
foreach(loop_var ${RSG_DEFS})
set(SPLINT_PARAMS ${SPLINT_PARAMS} -D${loop_var})
endforeach(loop_var ${RSG_DEFS})
set(SPLINT_PARAMS ${SPLINT_PARAMS}
- -I${RSG_SRC_DIR} -warnposix)
+ -I${RSG_SRC_DIR} +posixlib)
set(SPLINT_PARAMS ${SPLINT_PARAMS} ${RSGSRC})
add_custom_target(splint ${SPLINT_PATH} ${SPLINT_PARAMS}
VERBATIM)
View
4 src/common.h
@@ -26,7 +26,9 @@
#include <time.h>
#include "thirdparty/logger.h"
#ifndef _WIN32
-# include <unistd.h>
+# ifndef S_SPLINT_S
+# include <unistd.h>
+# endif
#endif
/*@end@*/
View
4 src/gamma.c
@@ -242,9 +242,9 @@ int gamma_calc_temp(double elevation, int temp_day, int temp_night)
int size;
pair *map = opt_get_map(&size);
double prevelev=map[size-1].elev+360;
- int prevtemp=map[size-1].temp;
+ double prevtemp=map[size-1].temp;
double currelev;
- int currtemp;
+ double currtemp;
for( i = 0; i<size+1; ++i ){
if( i==size ){
currelev = map[0].elev-360.0;
View
2  src/gamma.h
@@ -40,7 +40,7 @@ typedef struct{
/**\brief Elevation in degrees */
double elev;
/**\brief Temperature as percentage */
- int temp;
+ double temp;
} pair;
/**\brief Maps temperature to RGB */
View
2  src/gui/iupgui_settings.c
@@ -236,7 +236,7 @@ static Ihandle *_settings_create_elev(void){
for( i=0; i<size; ++i ){
// Use up LINE_SIZE of buffer, with NULL terminator being overwritten on
// next loop
- snprintf(txt_val+LINE_SIZE*i,LINE_SIZE+1,"%9.2f,%7d%%;\n",
+ snprintf(txt_val+LINE_SIZE*i,LINE_SIZE+1,"%9.2f,%7f%%;\n",
map[i].elev,map[i].temp);
}
edt_elev = IupSetAtt(NULL,IupText(NULL),
View
18 src/location.c
@@ -18,7 +18,8 @@ int location_geocode_hostip(float *lat,float *lon,char *city,int bsize){
(*lat)=parse_tag_float(result,"Latitude: ");
(*lon)=parse_tag_float(result,"Longitude: ");
- if( !parse_tag_str(result,"City: ","\n",city,bsize) ){
+ if( parse_tag_str(result,"City: ","\n",city,bsize)
+ != RET_FUN_SUCCESS ){
free(result);
return RET_FUN_FAILED;
}
@@ -46,7 +47,7 @@ int location_geocode_geobytes(float *lat,float *lon,char *city,int bsize){
(*lon)=parse_tag_float(result,"\"longitude\":");
size_copied=parse_tag_str(result,"\"city\":\"","\",",city,bsize);
- if( !size_copied ){
+ if( size_copied==0 ){
free(result);
return RET_FUN_FAILED;
}
@@ -58,7 +59,7 @@ int location_geocode_geobytes(float *lat,float *lon,char *city,int bsize){
city[size_used++]=',';
size_copied=parse_tag_str(result,"\"region\":\"","\",",city+size_used,
bsize-size_used);
- if( !size_used ){
+ if( size_copied==0 ){
free(result);
return RET_FUN_FAILED;
}
@@ -70,7 +71,7 @@ int location_geocode_geobytes(float *lat,float *lon,char *city,int bsize){
city[size_used++]=',';
size_copied=parse_tag_str(result,"\"country\":\"","\",",city+size_used,
bsize-size_used);
- if( !size_used ){
+ if( size_copied==0 ){
free(result);
return RET_FUN_FAILED;
}
@@ -92,9 +93,11 @@ int location_address_lookup(char *address,float *lat,float *lon,
if( !escaped_url )
return RET_FUN_FAILED;
- url=malloc((strlen(baseurl)+strlen(escaped_url)+1)*sizeof(char));
+ url=malloc((strlen(baseurl)
+ +strlen(escaped_url)+1)*sizeof(char));
if( !url ){
LOG(LOGERR,_("Allocation of URL failed"));
+ free(escaped_url);
return RET_FUN_FAILED;
}
strcpy(url,baseurl);
@@ -115,8 +118,9 @@ int location_address_lookup(char *address,float *lat,float *lon,
(*lat)=parse_tag_float(result,"<lat>");
(*lon)=parse_tag_float(result,"<lng>");
- if( !parse_tag_str(result,"<formatted_address>","</formatted_address>",
- city,bsize) ){
+ if( parse_tag_str(result,"<formatted_address>",
+ "</formatted_address>",city,bsize)
+ != RET_FUN_SUCCESS ){
free(result);
return RET_FUN_FAILED;
}
View
35 src/netutils.c
@@ -16,10 +16,12 @@ struct MemoryStruct {
/**\brief Size of buffer */
size_t size;
};
-static CURL *curl;
+/*@keep@*/ static CURL *curl;
// Allocate or re-size buffer
-static void *_myrealloc(void *ptr, size_t size){
+static /*@null@*//*@partial@*/ void *_myrealloc(
+ /*@only@*/ void *ptr, size_t size)
+{
if(ptr)
return realloc(ptr, size);
else
@@ -36,7 +38,7 @@ static size_t _writememcb(void *ptr, size_t size,
if( mem->memory ){
memcpy(&(mem->memory[mem->size]),ptr,realsize);
mem->size += realsize;
- mem->memory[mem->size] = 0;
+ mem->memory[mem->size] = '\0';
}
LOG(LOGINFO,_("Downloading data..."));
return realsize;
@@ -51,9 +53,9 @@ char *download2buffer(char url[]){
chunk.memory = NULL;
chunk.size = 0;
LOG(LOGINFO,_("Downloading URL: %s"),url);
- curl_easy_setopt(curl,CURLOPT_URL,url);
- curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,_writememcb);
- curl_easy_setopt(curl,CURLOPT_WRITEDATA,(void*)&chunk);
+ (void)curl_easy_setopt(curl,CURLOPT_URL,url);
+ (void)curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,_writememcb);
+ (void)curl_easy_setopt(curl,CURLOPT_WRITEDATA,(void*)&chunk);
res = curl_easy_perform(curl);
if( res != 0 ){
// Error occurred
@@ -68,7 +70,8 @@ char *download2buffer(char url[]){
}
// Escape special character in URL
-char *escape_url(char url[]){
+char *escape_url(char url[])
+{
struct{char ch;char code[3];} specials[]={
{' ', "20"},
{'<', "3C"},
@@ -93,13 +96,13 @@ char *escape_url(char url[]){
{'&', "26"},
{'$', "24"},
};
- int i,j,k;
- int size=strlen(url);
- int newsize=size+1;
+ unsigned int i,j,k;
+ unsigned int size=(unsigned int)strlen(url);
+ unsigned int newsize=size+1;
char *escaped_url=NULL;
for( i=0; i<size; ++i ){
- for( j=0; j<SIZEOF(specials); ++j ){
+ for( j=0; j<((unsigned int)SIZEOF(specials));++j ){
if( url[i]==specials[j].ch ){
newsize+=2;
break;
@@ -115,7 +118,7 @@ char *escape_url(char url[]){
k=0;
while( i<newsize ){
escaped_url[i]=url[k];
- for( j=0; j<SIZEOF(specials); ++j ){
+ for( j=0; j<((unsigned int)SIZEOF(specials)); ++j ){
if( url[k]==specials[j].ch ){
escaped_url[i]='%';
escaped_url[++i]=specials[j].code[0];
@@ -128,7 +131,7 @@ char *escape_url(char url[]){
}
LOG(LOGVERBOSE,_("Old URL is %s"),url);
LOG(LOGVERBOSE,_("Escaped URL is: %s"),escaped_url);
- return escaped_url;
+ return /*@i1@*/ escaped_url;
}
/* Copies content of tag to buffer
@@ -146,7 +149,7 @@ int parse_tag_str(char content[],char start_tag[],char end_tag[],
LOG(LOGWARN,_("Buffer to small for [%s]-[%s]"),start_tag,end_tag);
length = bsize-1;
}
- strncpy(buffer,begin,length);
+ strncpy(buffer,begin,(size_t)length);
buffer[length]='\0';
return length;
}else{
@@ -163,7 +166,7 @@ int parse_tag_str(char content[],char start_tag[],char end_tag[],
*/
float parse_tag_float(char content[],char start[]){
char *searchind;
- int size=strlen(start);
+ int size=(int)strlen(start);
searchind=strstr(content,start);
if( searchind )
@@ -173,7 +176,7 @@ float parse_tag_float(char content[],char start[]){
}
int net_init(void){
- curl_global_init(CURL_GLOBAL_ALL);
+ (void)curl_global_init(CURL_GLOBAL_ALL);
curl = curl_easy_init();
if( curl )
return RET_FUN_SUCCESS;
View
7 src/netutils.h
@@ -8,15 +8,16 @@
#define __NETUTILS_H__
/**\brief Downloads url content to a new buffer, you must free buffer */
-char *download2buffer(char url[]);
+/*@null@*/ char *download2buffer(char url[]);
/**\brief Escapes special characters in URL (makes a new buffer you must free) */
-char *escape_url(char url[]);
+/*@null@*/ char *escape_url(char url[]);
/**\brief Parses a string given starting and ending tags, you must supply buffer
* \return strlen of copied string (maybe truncated if buffer too small).
*/
-int parse_tag_str(char content[],char start_tag[],char end_tag[],char *buffer,int bsize);
+int parse_tag_str(char content[],char start_tag[],char end_tag[],
+ /*@unique@*/ char *buffer,int bsize);
/**\brief Parses a float given starting tag */
float parse_tag_float(char content[],char start[]);
View
72 src/options.c
@@ -44,7 +44,7 @@ typedef struct{
int startdisabled;
#endif//ENABLE_IUP
/**\brief Temperature map (Advanced) */
- pair *map;
+ /*@null@*//*@partial@*//*@owned@*/ pair *map;
/**\brief Temperature map size (Advanced) */
int map_size;
} rs_opts;
@@ -64,33 +64,41 @@ int opt_get_config_file(char buffer[],size_t bufsize){
#else
char *home = getenv("APPDATA");
#endif
- size_t s_home = strlen(home);
+ size_t s_home;
+ if( home==NULL ){
+ strcpy(buffer,"None");
+ return RET_FUN_FAILED;
+ }
+ s_home = strlen(home);
if( s_home < (bufsize+strlen(RSG_RCFILE)-5) ){
strcpy(buffer,home);
buffer[s_home++]=PATH_SEP;
strcpy(buffer+s_home,RSG_RCFILE);
- return 1;
+ return RET_FUN_SUCCESS;
}
- return 0;
+ strcpy(buffer,"TooLong");
+ return RET_FUN_FAILED;
}
// Load defaults
void opt_init(void){
+ if( Rs_opts.map!=NULL )
+ free(Rs_opts.map);
Rs_opts.map=NULL;
- opt_set_verbose(0);
- opt_set_brightness(1.0);
- opt_set_location(0,0);
- opt_set_temperatures(DEFAULT_DAY_TEMP,DEFAULT_NIGHT_TEMP);
- opt_set_gamma(DEFAULT_GAMMA,DEFAULT_GAMMA,DEFAULT_GAMMA);
- opt_set_method(GAMMA_METHOD_AUTO);
- opt_set_screen(-1);
- opt_set_crtc(-1);
- opt_set_transpeed(1000);
- opt_set_oneshot(0);
- opt_set_nogui(0);
+ (void)opt_set_verbose(0);
+ (void)opt_set_brightness(1.0);
+ (void)opt_set_location(0,0);
+ (void)opt_set_temperatures(DEFAULT_DAY_TEMP,DEFAULT_NIGHT_TEMP);
+ (void)opt_set_gamma(DEFAULT_GAMMA,DEFAULT_GAMMA,DEFAULT_GAMMA);
+ (void)opt_set_method(GAMMA_METHOD_AUTO);
+ (void)opt_set_screen(-1);
+ (void)opt_set_crtc(-1);
+ (void)opt_set_transpeed(1000);
+ (void)opt_set_oneshot(0);
+ (void)opt_set_nogui(0);
#ifdef ENABLE_IUP
- opt_set_min(0);
- opt_set_disabled(0);
+ (void)opt_set_min(0);
+ (void)opt_set_disabled(0);
#endif//ENABLE_IUP
}
@@ -253,7 +261,7 @@ int opt_parse_temperatures(char *val){
// Sets the verbosity of logging
int opt_set_verbose(int level){
Rs_opts.verbose = level;
- log_setlevel(level+2);
+ (void)log_setlevel(level+2);
return RET_FUN_SUCCESS;
}
@@ -299,21 +307,21 @@ int opt_parse_map(char *map){
currsep=strchr(currstr,',');
currend=strchr(currstr,';');
curr_map[i].elev=atof(currstr);
- curr_map[i].temp=atoi(++currsep);
+ curr_map[i].temp=atof(++currsep);
if( curr_map[i].elev > prevelev ){
free(curr_map);
LOG(LOGERR,_("Invalid map line, elevation must be decreasing."));
return RET_FUN_FAILED;
}
prevelev = curr_map[i].elev;
- if( (curr_map[i].temp>100)
- || (curr_map[i].temp<0) ){
+ if( (curr_map[i].temp>100.0)
+ /*@i@*/|| (curr_map[i].temp<0.0) ){
free(curr_map);
LOG(LOGERR,_("Invalid map line, temperature must be between 0-100%."));
return RET_FUN_FAILED;
}
- LOG(LOGVERBOSE,_("Map line: %f,%d"),curr_map[i].elev,
+ /*@i@*/LOG(LOGVERBOSE,_("Map line: %f,%d"),curr_map[i].elev,
curr_map[i].temp);
currstr=++currend;
}
@@ -373,16 +381,16 @@ int opt_get_disabled(void)
pair *opt_get_map(int *size){
if( !Rs_opts.map ){
- (*size)=SIZEOF(default_map);
+ (*size)=(int)SIZEOF(default_map);
return default_map;
}else{
- (*size)=Rs_opts.map_size;
+ (*size)=(int)Rs_opts.map_size;
return Rs_opts.map;
}
}
temp_gamma *opt_get_gammap(int *size){
- (*size)=SIZEOF(blackbody_color);
+ (*size)=(int)SIZEOF(blackbody_color);
return blackbody_color;
}
@@ -391,11 +399,15 @@ void opt_write_config(void){
char Config_file[LONGEST_PATH];
FILE *fid_config;
- opt_get_config_file(Config_file,LONGEST_PATH);
+ if(opt_get_config_file(Config_file,LONGEST_PATH)
+ !=RET_FUN_SUCCESS)
+ return;
fid_config = fopen(Config_file,"w");
- if(opt_get_min())
+ if( fid_config==NULL )
+ return;
+ if( opt_get_min()!=0 )
fprintf(fid_config,"min\n");
- if(opt_get_disabled())
+ if( opt_get_disabled()!=0 )
fprintf(fid_config,"disable\n");
fprintf(fid_config,"temps=%d:%d\n",opt_get_temp_day(),opt_get_temp_night());
fprintf(fid_config,"latlon=%f:%f\n",opt_get_lat(),opt_get_lon());
@@ -405,10 +417,10 @@ void opt_write_config(void){
int i;
fprintf(fid_config,"map=");
for( i=0; i<Rs_opts.map_size; ++i )
- fprintf(fid_config,"%.2f,%d;",Rs_opts.map[i].elev,Rs_opts.map[i].temp);
+ fprintf(fid_config,"%.2f,%.2f;",Rs_opts.map[i].elev,Rs_opts.map[i].temp);
fprintf(fid_config,"\n");
}
- fclose(fid_config);
+ (void)fclose(fid_config);
}
/* Frees resources used by options */
View
2  src/options.h
@@ -28,7 +28,7 @@
* \param buffer buffer to store the configuration file.
* \param bufsize size of the buffer.
*/
-int opt_get_config_file(char buffer[],size_t bufsize);
+int opt_get_config_file(/*@out@*/ char buffer[],size_t bufsize);
/**\brief Load default values for all fields.
*/
Please sign in to comment.
Something went wrong with that request. Please try again.