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 MattArsenault, 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 = \ 
    2727        -I$(top_srcdir)/lib/mac                 \
    2828        $(PTHREAD_CFLAGS)
    2929
    30 AM_CFLAGS =
     30AM_CFLAGS = -Wall -Wextra -Wshadow -Wredundant-decls -Winline -Wdisabled-optimization -Wpointer-arith -Wstrict-aliasing
    3131
    32 AM_CXXFLAGS =
     32AM_CXXFLAGS = $(AM_CFLAGS)
    3333
    3434AM_LDFLAGS =
    3535
  • 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 { 
    951951    int pid;
    952952#endif
    953953    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
     959void GRAPHICS_APP::run(char* path) {
     960    int argc;
     961    char* argv[4];
     962    char abspath[1024];
    958963#ifdef _WIN32
    959         GetFullPathName(path, 1024, abspath, NULL);
     964    GetFullPathName(path, 1024, abspath, NULL);
    960965#else
    961         strcpy(abspath, path);
     966    strcpy(abspath, path);
    962967#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;
    976976    }
    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) {
    979979        pid = 0;
    980         return false;
    981980    }
    982     void kill() {
    983         if (pid) {
    984             kill_program(pid);
    985             pid = 0;
    986         }
     981}
     982
     983
     984bool GRAPHICS_APP::is_running() {
     985    if (pid && process_exists(pid)) return true;
     986    pid = 0;
     987    return false;
     988}
     989
     990
     991void GRAPHICS_APP::kill() {
     992    if (pid) {
     993        kill_program(pid);
     994        pid = 0;
    987995    }
    988 };
     996}
    989997
    990998static GRAPHICS_APP ga_win(false), ga_full(true);
    991999static 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){ 
    154154        }
    155155        fprintf(stderr, "texfont: tried to access unavailable font character \"%c\" (%d)\n",isprint(c) ? c : ' ', c);
    156156        abort();
    157         // NOT REACHED 
     157        // NOT REACHED
    158158        return NULL;
    159159}
    160160
    161161
    162 static char *lastError;
     162static const char *lastError;
    163163
    164164
    165 char * txfErrorString(void) {
     165const char * txfErrorString(void) {
    166166        return lastError;
    167167}
    168168
  • api/texfont.h

    diff --git a/api/texfont.h b/api/texfont.h
    index efe57e8..cd75232 100644
    a b typedef struct { 
    6161        TexGlyphVertexInfo **lut;
    6262} TexFont;
    6363
    64 extern char *txfErrorString(void);
     64extern const char *txfErrorString(void);
    6565
    6666extern TexFont *txfLoadFont(const char *filename);
    6767
  • lib/app_ipc.cpp

    diff --git a/lib/app_ipc.cpp b/lib/app_ipc.cpp
    index 31a08ab..dc3f7de 100644
    a b  
    3636#include "str_replace.h"
    3737#include "str_util.h"
    3838#include "url.h"
    39 
    4039#include "app_ipc.h"
     40#include "boinc_api.h"
    4141
    4242using std::string;
    4343
  • 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); 
    232232
    233233extern const char* xml_graphics_modes[NGRAPHICS_MSGS];
    234234extern int boinc_link(const char* phys_name, const char* logical_name);
    235 
    236 #ifdef __cplusplus
    237 extern "C" {
    238 #endif
    239 
    240 extern int boinc_resolve_filename(const char*, char*, int len);
    241 
    242 #ifdef __cplusplus
    243 } // extern "C" {
    244 #endif
    245 
    246235extern void url_to_project_dir(char* url, char* dir);
    247236
    248237#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) { 
    542542    return ERR_XML_PARSE;
    543543}
    544544
     545void 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
     567void COPROC::clear_usage() {
     568    for (int i=0; i<count; i++) {
     569        usage[i] = 0;
     570        pending_usage[i] = 0;
     571    }
     572}
     573
    545574void COPROC_ATI::description(char* buf) {
    546575    sprintf(buf, "%s (CAL version %s, %.0fMB, %.0f GFLOPS peak)",
    547576        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 { 
    168168    int parse(XML_PARSER&);
    169169#endif
    170170
    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
    200174    COPROC(const char* t){
    201175        clear();
    202176        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) { 
    110110    return dst;
    111111}
    112112
     113int MIOFILE::_getc() {
     114    if (f) {
     115        return fgetc(f);
     116    }
     117    return (*buf)?(*buf++):EOF;
     118}
     119
     120
    113121int MIOFILE::_ungetc(int c) {
    114122    if (f) {
    115123#ifdef _USING_FCGI_
  • lib/miofile.h

    diff --git a/lib/miofile.h b/lib/miofile.h
    index f86e1d3..dc053dd 100644
    a b public: 
    6565    char* fgets(char*, int);
    6666    int _ungetc(int);
    6767    bool eof();
    68     inline int _getc() {
    69         if (f) {
    70             return fgetc(f);
    71         }
    72         return (*buf)?(*buf++):EOF;
    73     }
     68    int _getc();
    7469};
    7570
    7671extern 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) { 
    538538    }
    539539}
    540540
     541
     542bool match_tag(const char* buf, const char* tag) {
     543    if (strstr(buf, tag)) return true;
     544    return false;
     545}
     546
     547bool 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//
     556bool 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//
     567bool 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
    541580// we just read a <; read until we find a >.
    542581// Given <tag [attr=val attr=val] [/]>:
    543582// - 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); 
    5555
    5656// return true if the tag appears in the line
    5757//
    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 }
     58extern bool match_tag(const char* buf, const char* tag);
     59extern bool match_tag(const std::string &s, const char* tag);
     60extern bool parse_int(const char* buf, const char* tag, int& x);
     61extern bool parse_double(const char* buf, const char* tag, double& x);
    9362
    9463extern bool parse(char* , char* );
    9564extern 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 { 
    156156
    157157// TIME_PREFS implementation
    158158
     159TIME_PREFS::TIME_PREFS(double start, double end) {
     160    start_hour = start;
     161    end_hour = end;
     162}
     163
    159164void TIME_PREFS::clear() {
    160165    start_hour = 0;
    161166    end_hour = 0;
    bool TIME_PREFS::suspended() const { 
    179184
    180185// WEEK_PREFS implementation
    181186
     187WEEK_PREFS::WEEK_PREFS() {
     188    clear();
     189}
     190
     191void WEEK_PREFS::clear() {
     192    memset(this, 0, sizeof(WEEK_PREFS));
     193}
     194
    182195
    183196void WEEK_PREFS::set(int day, double start, double end) {
    184197    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 { 
    9999
    100100struct WEEK_PREFS {
    101101    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();
    109104
    110105    void set(int day, double start, double end);
    111106    void set(int day, TIME_SPAN* time);
    struct TIME_PREFS : public TIME_SPAN { 
    120115    WEEK_PREFS week;
    121116
    122117    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);
    128119    void clear();
    129120    bool suspended() const;
    130    
     121
    131122};
    132123
    133124
  • 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( 
    716716    return retval;
    717717}
    718718
    719 inline void remove_str(char* p, const char* str) {
     719void remove_str(char* p, const char* str) {
    720720    size_t n = strlen(str);
    721721    while (1) {
    722722        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&); 
    6666
    6767extern int boinc_calling_thread_cpu_time(double&);
    6868
    69 // convert UNIX time to MySQL timestamp (yyyymmddhhmmss)
    70 //
    71 extern void mysql_timestamp(double, char*);
    72 
    7369// fake a crash
    7470//
    7571extern void boinc_crash();