Ticket #1116: 0004-Fix-various-warnings.-Mostly-inlining-failed-and-red.patch
File 0004-Fix-various-warnings.-Mostly-inlining-failed-and-red.patch, 12.8 KB (added by , 13 years ago) |
---|
-
Makefile.incl
From c367f1c38bad90f55d48eda62740f1a2f1eb7c0e Mon Sep 17 00:00:00 2001 From: Matt Arsenault <arsenm2@rpi.edu> Date: Wed, 22 Jun 2011 18:29:19 -0400 Subject: [PATCH 4/6] Fix various warnings. Mostly inlining failed and redundant declarations --- Makefile.incl | 4 +- api/boinc_api.cpp | 64 +++++++++++++++++++++++++++++----------------------- api/texfont.cpp | 6 ++-- api/texfont.h | 2 +- lib/app_ipc.cpp | 2 +- lib/app_ipc.h | 11 --------- lib/coproc.cpp | 29 ++++++++++++++++++++++++ lib/coproc.h | 32 ++------------------------ lib/miofile.cpp | 8 ++++++ lib/miofile.h | 7 +----- lib/parse.cpp | 39 ++++++++++++++++++++++++++++++++ lib/parse.h | 39 +++----------------------------- lib/prefs.cpp | 13 ++++++++++ lib/prefs.h | 17 +++---------- lib/str_util.cpp | 2 +- lib/util.h | 4 --- 16 files changed, 145 insertions(+), 134 deletions(-) diff --git a/Makefile.incl b/Makefile.incl index 51067e7..568cba6 100644
a b AM_CPPFLAGS = \ 27 27 -I$(top_srcdir)/lib/mac \ 28 28 $(PTHREAD_CFLAGS) 29 29 30 AM_CFLAGS = 30 AM_CFLAGS = -Wall -Wextra -Wshadow -Wredundant-decls -Winline -Wdisabled-optimization -Wpointer-arith -Wstrict-aliasing 31 31 32 AM_CXXFLAGS = 32 AM_CXXFLAGS = $(AM_CFLAGS) 33 33 34 34 AM_LDFLAGS = 35 35 -
api/boinc_api.cpp
diff --git a/api/boinc_api.cpp b/api/boinc_api.cpp index 95c313c..714e2ce 100644
a b struct GRAPHICS_APP { 951 951 int pid; 952 952 #endif 953 953 GRAPHICS_APP(bool f) {fullscreen=f;} 954 void run(char* path) { 955 int argc; 956 char* argv[4]; 957 char abspath[1024]; 954 void run(char* path); 955 bool is_running(); 956 void kill(); 957 }; 958 959 void GRAPHICS_APP::run(char* path) { 960 int argc; 961 char* argv[4]; 962 char abspath[1024]; 958 963 #ifdef _WIN32 959 964 GetFullPathName(path, 1024, abspath, NULL); 960 965 #else 961 966 strcpy(abspath, path); 962 967 #endif 963 argv[0] = (char*)GRAPHICS_APP_FILENAME; 964 if (fullscreen) { 965 argv[1] = (char*)"--fullscreen"; 966 argv[2] = 0; 967 argc = 2; 968 } else { 969 argv[1] = 0; 970 argc = 1; 971 } 972 int retval = run_program(0, abspath, argc, argv, 0, pid); 973 if (retval) { 974 pid = 0; 975 } 968 argv[0] = (char*)GRAPHICS_APP_FILENAME; 969 if (fullscreen) { 970 argv[1] = (char*)"--fullscreen"; 971 argv[2] = 0; 972 argc = 2; 973 } else { 974 argv[1] = 0; 975 argc = 1; 976 976 } 977 bool is_running() {978 if (pid && process_exists(pid)) return true;977 int retval = run_program(0, abspath, argc, argv, 0, pid); 978 if (retval) { 979 979 pid = 0; 980 return false;981 980 } 982 void kill() { 983 if (pid) { 984 kill_program(pid); 985 pid = 0; 986 } 981 } 982 983 984 bool GRAPHICS_APP::is_running() { 985 if (pid && process_exists(pid)) return true; 986 pid = 0; 987 return false; 988 } 989 990 991 void GRAPHICS_APP::kill() { 992 if (pid) { 993 kill_program(pid); 994 pid = 0; 987 995 } 988 } ;996 } 989 997 990 998 static GRAPHICS_APP ga_win(false), ga_full(true); 991 999 static bool have_graphics_app; -
api/texfont.cpp
diff --git a/api/texfont.cpp b/api/texfont.cpp index fdf2019..3ce7ae2 100644
a b static TexGlyphVertexInfo * getTCVI(TexFont * txf, int c){ 154 154 } 155 155 fprintf(stderr, "texfont: tried to access unavailable font character \"%c\" (%d)\n",isprint(c) ? c : ' ', c); 156 156 abort(); 157 // NOT REACHED 157 // NOT REACHED 158 158 return NULL; 159 159 } 160 160 161 161 162 static c har *lastError;162 static const char *lastError; 163 163 164 164 165 c har * txfErrorString(void) {165 const char * txfErrorString(void) { 166 166 return lastError; 167 167 } 168 168 -
api/texfont.h
diff --git a/api/texfont.h b/api/texfont.h index efe57e8..cd75232 100644
a b typedef struct { 61 61 TexGlyphVertexInfo **lut; 62 62 } TexFont; 63 63 64 extern c har *txfErrorString(void);64 extern const char *txfErrorString(void); 65 65 66 66 extern TexFont *txfLoadFont(const char *filename); 67 67 -
lib/app_ipc.cpp
diff --git a/lib/app_ipc.cpp b/lib/app_ipc.cpp index 31a08ab..dc3f7de 100644
a b 36 36 #include "str_replace.h" 37 37 #include "str_util.h" 38 38 #include "url.h" 39 40 39 #include "app_ipc.h" 40 #include "boinc_api.h" 41 41 42 42 using std::string; 43 43 -
lib/app_ipc.h
diff --git a/lib/app_ipc.h b/lib/app_ipc.h index 699362e..8266632 100644
a b int parse_graphics_file(FILE* f, GRAPHICS_INFO* gi); 232 232 233 233 extern const char* xml_graphics_modes[NGRAPHICS_MSGS]; 234 234 extern int boinc_link(const char* phys_name, const char* logical_name); 235 236 #ifdef __cplusplus237 extern "C" {238 #endif239 240 extern int boinc_resolve_filename(const char*, char*, int len);241 242 #ifdef __cplusplus243 } // extern "C" {244 #endif245 246 235 extern void url_to_project_dir(char* url, char* dir); 247 236 248 237 #endif -
lib/coproc.cpp
diff --git a/lib/coproc.cpp b/lib/coproc.cpp index 7c151c2..cdcbb1a 100644
a b int COPROC_ATI::parse(MIOFILE& fin) { 542 542 return ERR_XML_PARSE; 543 543 } 544 544 545 void COPROC::clear() { 546 type[0] = 0; 547 count = 0; 548 used = 0; 549 have_cuda = false; 550 have_cal = false; 551 have_opencl = false; 552 req_secs = 0; 553 req_instances = 0; 554 opencl_device_count = 0; 555 estimated_delay = 0; 556 for (int i=0; i<MAX_COPROC_INSTANCES; i++) { 557 device_nums[i] = 0; 558 opencl_device_ids[i] = 0; 559 running_graphics_app[i] = true; 560 available_ram[i] = 0; 561 available_ram_fake[i] = 0; 562 available_ram_unknown[i] = true; 563 } 564 memset(&opencl_prop, 0, sizeof(opencl_prop)); 565 } 566 567 void COPROC::clear_usage() { 568 for (int i=0; i<count; i++) { 569 usage[i] = 0; 570 pending_usage[i] = 0; 571 } 572 } 573 545 574 void COPROC_ATI::description(char* buf) { 546 575 sprintf(buf, "%s (CAL version %s, %.0fMB, %.0f GFLOPS peak)", 547 576 name, version, attribs.localRAM/1024.*1024., peak_flops/1.e9 -
lib/coproc.h
diff --git a/lib/coproc.h b/lib/coproc.h index 89371c6..ee9451f 100644
a b struct COPROC { 168 168 int parse(XML_PARSER&); 169 169 #endif 170 170 171 inline void clear() { 172 // can't just memcpy() - trashes vtable 173 type[0] = 0; 174 count = 0; 175 peak_flops = 0; 176 used = 0; 177 have_cuda = false; 178 have_cal = false; 179 have_opencl = false; 180 req_secs = 0; 181 req_instances = 0; 182 opencl_device_count = 0; 183 estimated_delay = 0; 184 for (int i=0; i<MAX_COPROC_INSTANCES; i++) { 185 device_nums[i] = 0; 186 opencl_device_ids[i] = 0; 187 running_graphics_app[i] = true; 188 available_ram[i] = 0; 189 available_ram_fake[i] = 0; 190 available_ram_unknown[i] = true; 191 } 192 memset(&opencl_prop, 0, sizeof(opencl_prop)); 193 } 194 inline void clear_usage() { 195 for (int i=0; i<count; i++) { 196 usage[i] = 0; 197 pending_usage[i] = 0; 198 } 199 } 171 void clear(); 172 void clear_usage(); 173 200 174 COPROC(const char* t){ 201 175 clear(); 202 176 strcpy(type, t); -
lib/miofile.cpp
diff --git a/lib/miofile.cpp b/lib/miofile.cpp index 11b72db..cb9f3f8 100644
a b char* MIOFILE::fgets(char* dst, int dst_len) { 110 110 return dst; 111 111 } 112 112 113 int MIOFILE::_getc() { 114 if (f) { 115 return fgetc(f); 116 } 117 return (*buf)?(*buf++):EOF; 118 } 119 120 113 121 int MIOFILE::_ungetc(int c) { 114 122 if (f) { 115 123 #ifdef _USING_FCGI_ -
lib/miofile.h
diff --git a/lib/miofile.h b/lib/miofile.h index f86e1d3..dc053dd 100644
a b public: 65 65 char* fgets(char*, int); 66 66 int _ungetc(int); 67 67 bool eof(); 68 inline int _getc() { 69 if (f) { 70 return fgetc(f); 71 } 72 return (*buf)?(*buf++):EOF; 73 } 68 int _getc(); 74 69 }; 75 70 76 71 extern int copy_element_contents(MIOFILE& in, const char* end_tag, char* p, int len); -
lib/parse.cpp
diff --git a/lib/parse.cpp b/lib/parse.cpp index 4fda9ee..5e7afb5 100644
a b int XML_PARSER::scan_cdata(char* buf, int len) { 538 538 } 539 539 } 540 540 541 542 bool match_tag(const char* buf, const char* tag) { 543 if (strstr(buf, tag)) return true; 544 return false; 545 } 546 547 bool match_tag(const std::string &s, const char* tag) { 548 return match_tag(s.c_str(), tag); 549 } 550 551 552 // parse an integer of the form <tag>1234</tag> 553 // return true if it's there 554 // Note: this doesn't check for the end tag 555 // 556 bool parse_int(const char* buf, const char* tag, int& x) { 557 const char* p = strstr(buf, tag); 558 if (!p) return false; 559 int y = strtol(p+strlen(tag), 0, 0); // this parses 0xabcd correctly 560 if (errno == ERANGE) return false; 561 x = y; 562 return true; 563 } 564 565 // Same, for doubles 566 // 567 bool parse_double(const char* buf, const char* tag, double& x) { 568 double y; 569 const char* p = strstr(buf, tag); 570 if (!p) return false; 571 y = atof(p+strlen(tag)); 572 if (!boinc_is_finite(y)) { 573 return false; 574 } 575 x = y; 576 return true; 577 } 578 579 541 580 // we just read a <; read until we find a >. 542 581 // Given <tag [attr=val attr=val] [/]>: 543 582 // - copy tag (or tag/) to tag_buf -
lib/parse.h
diff --git a/lib/parse.h b/lib/parse.h index 07b92a4..e9cd2bd 100644
a b extern bool boinc_is_finite(double); 55 55 56 56 // return true if the tag appears in the line 57 57 // 58 inline bool match_tag(const char* buf, const char* tag) { 59 if (strstr(buf, tag)) return true; 60 return false; 61 } 62 63 inline bool match_tag(const std::string &s, const char* tag) { 64 return match_tag(s.c_str(), tag); 65 } 66 67 // parse an integer of the form <tag>1234</tag> 68 // return true if it's there 69 // Note: this doesn't check for the end tag 70 // 71 inline bool parse_int(const char* buf, const char* tag, int& x) { 72 const char* p = strstr(buf, tag); 73 if (!p) return false; 74 int y = strtol(p+strlen(tag), 0, 0); // this parses 0xabcd correctly 75 if (errno == ERANGE) return false; 76 x = y; 77 return true; 78 } 79 80 // Same, for doubles 81 // 82 inline bool parse_double(const char* buf, const char* tag, double& x) { 83 double y; 84 const char* p = strstr(buf, tag); 85 if (!p) return false; 86 y = atof(p+strlen(tag)); 87 if (!boinc_is_finite(y)) { 88 return false; 89 } 90 x = y; 91 return true; 92 } 58 extern bool match_tag(const char* buf, const char* tag); 59 extern bool match_tag(const std::string &s, const char* tag); 60 extern bool parse_int(const char* buf, const char* tag, int& x); 61 extern bool parse_double(const char* buf, const char* tag, double& x); 93 62 94 63 extern bool parse(char* , char* ); 95 64 extern bool parse_str(const char*, const char*, char*, int); -
lib/prefs.cpp
diff --git a/lib/prefs.cpp b/lib/prefs.cpp index 4c6dde6..a3ee8c0 100644
a b TIME_SPAN::TimeMode TIME_SPAN::mode() const { 156 156 157 157 // TIME_PREFS implementation 158 158 159 TIME_PREFS::TIME_PREFS(double start, double end) { 160 start_hour = start; 161 end_hour = end; 162 } 163 159 164 void TIME_PREFS::clear() { 160 165 start_hour = 0; 161 166 end_hour = 0; … … bool TIME_PREFS::suspended() const { 179 184 180 185 // WEEK_PREFS implementation 181 186 187 WEEK_PREFS::WEEK_PREFS() { 188 clear(); 189 } 190 191 void WEEK_PREFS::clear() { 192 memset(this, 0, sizeof(WEEK_PREFS)); 193 } 194 182 195 183 196 void WEEK_PREFS::set(int day, double start, double end) { 184 197 if (day < 0 || day > 6) return; -
lib/prefs.h
diff --git a/lib/prefs.h b/lib/prefs.h index b8ae89a..0054787 100644
a b struct TIME_SPAN { 99 99 100 100 struct WEEK_PREFS { 101 101 TIME_SPAN days[7]; 102 103 void clear() { 104 memset(this, 0, sizeof(WEEK_PREFS)); 105 } 106 WEEK_PREFS() { 107 clear(); 108 } 102 WEEK_PREFS(); 103 void clear(); 109 104 110 105 void set(int day, double start, double end); 111 106 void set(int day, TIME_SPAN* time); … … struct TIME_PREFS : public TIME_SPAN { 120 115 WEEK_PREFS week; 121 116 122 117 TIME_PREFS() {} 123 TIME_PREFS(double start, double end) { 124 start_hour = start; 125 end_hour = end; 126 } 127 118 TIME_PREFS(double start, double end); 128 119 void clear(); 129 120 bool suspended() const; 130 121 131 122 }; 132 123 133 124 -
lib/str_util.cpp
diff --git a/lib/str_util.cpp b/lib/str_util.cpp index 8e1b3a7..09971a6 100644
a b int string_substitute( 716 716 return retval; 717 717 } 718 718 719 inlinevoid remove_str(char* p, const char* str) {719 void remove_str(char* p, const char* str) { 720 720 size_t n = strlen(str); 721 721 while (1) { 722 722 p = strstr(p, str); -
lib/util.h
diff --git a/lib/util.h b/lib/util.h index 6b7093d..e40e679 100644
a b extern void update_average(double, double, double, double, double&, double&); 66 66 67 67 extern int boinc_calling_thread_cpu_time(double&); 68 68 69 // convert UNIX time to MySQL timestamp (yyyymmddhhmmss)70 //71 extern void mysql_timestamp(double, char*);72 73 69 // fake a crash 74 70 // 75 71 extern void boinc_crash();