Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++ code: eliminate a source of potential bugs #5771

Merged
merged 1 commit into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions client/client_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,9 @@ struct DAILY_STATS {
double host_expavg_credit;
double day;

DAILY_STATS(int){}
DAILY_STATS(DUMMY_TYPE){}
void clear() {
static const DAILY_STATS x(0);
static const DAILY_STATS x(DUMMY);
*this = x;
}
DAILY_STATS() {
Expand Down Expand Up @@ -299,9 +299,9 @@ struct APP {
bool ignore;
#endif

APP(int){}
APP(DUMMY_TYPE){}
void clear() {
static const APP x(0);
static const APP x(DUMMY);
*this = x;
}
APP(){
Expand Down
4 changes: 2 additions & 2 deletions client/net_stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ class NET_STATS {
NET_INFO up;
NET_INFO down;

NET_STATS(int){}
NET_STATS(DUMMY_TYPE){}
void clear() {
static const NET_STATS x(0);
static const NET_STATS x(DUMMY);
*this = x;
}
NET_STATS() {
Expand Down
4 changes: 2 additions & 2 deletions client/sim.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ struct SIM_RESULTS {
double idle_frac;
int nrpcs;

SIM_RESULTS(int){}
SIM_RESULTS(DUMMY_TYPE){}
void clear() {
static const SIM_RESULTS x(0);
static const SIM_RESULTS x(DUMMY);
*this = x;
}
SIM_RESULTS() {
Expand Down
4 changes: 2 additions & 2 deletions client/work_fetch.h
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,9 @@ struct PROJECT_WORK_FETCH {
// If we're uploading but a resource is idle, make a work request.
// If this succeeds, clear the flag.

PROJECT_WORK_FETCH(int) {}
PROJECT_WORK_FETCH(DUMMY_TYPE) {}
void clear() {
static const PROJECT_WORK_FETCH x(0);
static const PROJECT_WORK_FETCH x(DUMMY);
*this = x;
}
PROJECT_WORK_FETCH() {
Expand Down
8 changes: 8 additions & 0 deletions lib/common_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,14 @@ enum SPORADIC_AC_STATE {
#define CREDIT_TYPE_NETWORK 2
#define CREDIT_TYPE_PROJECT 3

// An arg type for the 'dummy constructors' used to zero out structs.
// Something that won't occur naturally, so that
// COPROC c = 0;
// will give a compile error, rather than creating a COPROC
// using a dummy COPROC(int) constructor
//
typedef enum DUMMY_ENUM{DUMMY=0} DUMMY_TYPE;

struct TIME_STATS {
double now;
// the client's current time of day
Expand Down
9 changes: 5 additions & 4 deletions lib/coproc.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
#include "cal_boinc.h"
#include "cl_boinc.h"
#include "opencl_boinc.h"
#include "common_defs.h"

#define MAX_COPROC_INSTANCES 64
#define MAX_RSC 8
Expand Down Expand Up @@ -205,9 +206,9 @@ struct COPROC {

OPENCL_DEVICE_PROP opencl_prop;

COPROC(int){}
COPROC(DUMMY_TYPE){}
inline void clear() {
static const COPROC x(0);
static const COPROC x(DUMMY);
*this = x;
}
COPROC(){
Expand Down Expand Up @@ -284,9 +285,9 @@ struct CUDA_DEVICE_PROP {
int deviceOverlap;
int multiProcessorCount;

CUDA_DEVICE_PROP(int){}
CUDA_DEVICE_PROP(DUMMY_TYPE){}
void clear() {
static const CUDA_DEVICE_PROP x(0);
static const CUDA_DEVICE_PROP x(DUMMY);
*this = x;
}
CUDA_DEVICE_PROP() {
Expand Down
1 change: 1 addition & 0 deletions lib/opencl_boinc.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#define BOINC_OPENCL_BOINC_H

#include "cl_boinc.h"
#include "common_defs.h"
#include "miofile.h"
#include "parse.h"

Expand Down
5 changes: 3 additions & 2 deletions lib/prefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include <cstdio>

#include "common_defs.h"
#include "miofile.h"
#include "parse.h"

Expand Down Expand Up @@ -74,9 +75,9 @@ struct GLOBAL_PREFS_MASK {
bool work_buf_additional_days;
bool work_buf_min_days;

GLOBAL_PREFS_MASK(int){}
GLOBAL_PREFS_MASK(DUMMY_TYPE){}
void clear() {
static const GLOBAL_PREFS_MASK x(0);
static const GLOBAL_PREFS_MASK x(DUMMY);
*this = x;
}
GLOBAL_PREFS_MASK() {
Expand Down
Loading