Commit 3ba7e1b9 authored by Christian Beer's avatar Christian Beer
Browse files

Merge pull request #1410 from BOINC/fix_coverity_defects

Fix coverity defects in client/ and lib/
parents f0df42ef 6a553cff
......@@ -457,6 +457,8 @@ STARFIELD::STARFIELD() {
stars = NULL;
zmax = 8;
zmaxinv = 1/zmax;
speed = 0;
nstars = 0;
}
//
......
......@@ -759,11 +759,13 @@ void ACCT_MGR_INFO::clear() {
strcpy(signing_key, "");
strcpy(previous_host_cpid, "");
strcpy(opaque, "");
strcpy(cookie_failure_url, "");
next_rpc_time = 0;
nfailures = 0;
send_gui_rpc_info = false;
password_error = false;
no_project_notices = false;
cookie_required = false;
}
ACCT_MGR_INFO::ACCT_MGR_INFO() {
......
......@@ -110,7 +110,16 @@ struct AM_ACCOUNT {
void handle_no_rsc(const char*, bool);
int parse(XML_PARSER&);
AM_ACCOUNT() {}
AM_ACCOUNT() {
strcpy(url_signature, "");
detach = false;
update = false;
dont_request_more_work.init();
detach_when_done.init();
resource_share.init();
suspend.init();
abort_not_started.init();
}
~AM_ACCOUNT() {}
};
......@@ -137,8 +146,12 @@ struct ACCT_MGR_OP: public GUI_HTTP_OP {
ACCT_MGR_OP(GUI_HTTP* p) {
gui_http = p;
global_prefs_xml = 0;
via_gui = false;
error_num = BOINC_SUCCESS;
repeat_sec = 60.0;
global_prefs_xml = 0;
strcpy(host_venue, "");
got_rss_feeds = false;
}
virtual ~ACCT_MGR_OP(){}
};
......
......@@ -102,6 +102,10 @@ struct GET_PROJECT_LIST_OP: public GUI_HTTP_OP {
struct PROJECT_ATTACH {
int error_num;
std::vector<std::string> messages;
PROJECT_ATTACH() {
error_num = 0;
messages.clear();
}
};
#endif
......@@ -89,6 +89,11 @@ ACTIVE_TASK::~ACTIVE_TASK() {
}
ACTIVE_TASK::ACTIVE_TASK() {
#ifdef _WIN32
strcpy(shmem_seg_name, "");
#else
shmem_seg_name = 0;
#endif
result = NULL;
wup = NULL;
app_version = NULL;
......@@ -111,6 +116,7 @@ ACTIVE_TASK::ACTIVE_TASK() {
first_fraction_done = 0;
first_fraction_done_elapsed_time = 0;
scheduler_state = CPU_SCHED_UNINITIALIZED;
next_scheduler_state = CPU_SCHED_UNINITIALIZED;
signal = 0;
run_interval_start_wall_time = gstate.now;
checkpoint_wall_time = 0;
......@@ -120,11 +126,16 @@ ACTIVE_TASK::ACTIVE_TASK() {
bytes_sent = 0;
bytes_received = 0;
strcpy(slot_dir, "");
strcpy(slot_path, "");
max_elapsed_time = 0;
max_disk_usage = 0;
max_mem_usage = 0;
have_trickle_down = false;
send_upload_file_status = false;
too_large = false;
needs_shmem = false;
want_network = 0;
abort_time = 0;
premature_exit_count = 0;
quit_time = 0;
procinfo.clear();
......
......@@ -552,7 +552,7 @@ static int get_priority(bool is_high_priority) {
// If "test" is set, we're doing the API test; just run "test_app".
//
int ACTIVE_TASK::start(bool test) {
char exec_name[256], file_path[MAXPATHLEN], buf[256], exec_path[MAXPATHLEN];
char exec_name[256], file_path[MAXPATHLEN], buf[MAXPATHLEN], exec_path[MAXPATHLEN];
char cmdline[80000]; // 64KB plus some extra
unsigned int i;
FILE_REF fref;
......@@ -1026,7 +1026,7 @@ int ACTIVE_TASK::start(bool test) {
#endif
char* p = getenv("LD_LIBRARY_PATH");
if (p) {
sprintf(libpath, "%s:%s", newlibs, p);
snprintf(libpath, sizeof(libpath), "%s:%s", newlibs, p);
} else {
safe_strcpy(libpath, newlibs);
}
......@@ -1037,7 +1037,7 @@ int ACTIVE_TASK::start(bool test) {
#ifdef __APPLE__
p = getenv("DYLD_LIBRARY_PATH");
if (p) {
sprintf(libpath, "%s:%s", newlibs, p);
snprintf(libpath, sizeof(libpath), "%s:%s", newlibs, p);
} else {
safe_strcpy(libpath, newlibs);
}
......
......@@ -78,6 +78,8 @@ ASYNC_COPY::ASYNC_COPY() {
in = out = NULL;
atp = NULL;
fip = NULL;
strcpy(to_path, "");
strcpy(temp_path, "");
}
ASYNC_COPY::~ASYNC_COPY() {
......
......@@ -68,7 +68,15 @@ struct ASYNC_VERIFY {
gzFile gzin;
char inpath[MAXPATHLEN], temp_path[MAXPATHLEN], outpath[MAXPATHLEN];
ASYNC_VERIFY(){};
ASYNC_VERIFY(){
fip = NULL;
in = NULL;
out = NULL;
gzin = NULL;
strcpy(inpath, "");
strcpy(temp_path, "");
strcpy(outpath, "");
};
~ASYNC_VERIFY(){};
int init(FILE_INFO*);
......
......@@ -93,9 +93,14 @@ CLIENT_STATE::CLIENT_STATE()
#ifndef SIM
scheduler_op = new SCHEDULER_OP(http_ops);
#endif
time_stats.init();
client_state_dirty = false;
old_major_version = 0;
old_minor_version = 0;
old_release = 0;
clock_change = false;
check_all_logins = false;
user_active = false;
cmdline_gui_rpc_port = 0;
run_cpu_benchmarks = false;
file_xfer_giveup_period = PERS_GIVEUP;
......@@ -103,6 +108,7 @@ CLIENT_STATE::CLIENT_STATE()
tasks_suspended = false;
tasks_throttled = false;
network_suspended = false;
file_xfers_suspended = false;
suspend_reason = 0;
network_suspend_reason = 0;
core_client_version.major = BOINC_MAJOR_VERSION;
......@@ -119,8 +125,13 @@ CLIENT_STATE::CLIENT_STATE()
app_started = 0;
exit_before_upload = false;
run_test_app = false;
#ifndef _WIN32
boinc_project_gid = 0;
#endif
show_projects = false;
strcpy(detach_project_url, "");
strcpy(reset_project_url, "");
strcpy(update_prefs_url, "");
strcpy(main_host_venue, "");
strcpy(attach_project_url, "");
strcpy(attach_project_auth, "");
......@@ -146,12 +157,18 @@ CLIENT_STATE::CLIENT_STATE()
redirect_io = false;
disable_graphics = false;
cant_write_state_file = false;
ncpus = 1;
benchmarks_running = false;
client_disk_usage = 0.0;
total_disk_usage = 0.0;
device_status_time = 0;
rec_interval_start = 0;
retry_shmem_time = 0;
total_cpu_time_this_rec_interval = 0.0;
must_enforce_cpu_schedule = false;
must_schedule_cpus = true;
must_check_work_fetch = true;
retry_shmem_time = 0;
no_gui_rpc = false;
gui_rpc_unix_domain = false;
new_version_check_time = 0;
......@@ -161,6 +178,8 @@ CLIENT_STATE::CLIENT_STATE()
g_use_sandbox = true; // User can override with -insecure command-line arg
#endif
launched_by_manager = false;
run_by_updater = false;
now = 0.0;
initialized = false;
last_wakeup_time = dtime();
device_status_time = 0;
......@@ -169,6 +188,13 @@ CLIENT_STATE::CLIENT_STATE()
#endif
}
CLIENT_STATE::~CLIENT_STATE() {
delete pers_file_xfers;
#ifndef SIM
delete scheduler_op;
#endif
}
void CLIENT_STATE::show_host_info() {
char buf[256], buf2[256];
......
......@@ -246,6 +246,7 @@ struct CLIENT_STATE {
// --------------- client_state.cpp:
CLIENT_STATE();
~CLIENT_STATE();
void show_host_info();
bool is_new_client();
int init();
......
......@@ -191,6 +191,7 @@ FILE_INFO::FILE_INFO() {
sticky_lifetime = 0;
sticky_expire_time = 0;
gzip_when_done = false;
ref_cnt = 0;
download_gzipped = false;
signature_required = false;
is_user_file = false;
......@@ -758,26 +759,35 @@ int FILE_INFO::gunzip(char* md5_buf) {
void APP_VERSION::init() {
strcpy(app_name, "");
strcpy(api_version, "");
version_num = 0;
strcpy(platform, "");
strcpy(plan_class, "");
strcpy(cmdline, "");
strcpy(file_prefix, "");
strcpy(api_version, "");
avg_ncpus = 1;
max_ncpus = 1;
gpu_usage.rsc_type = 0;
gpu_usage.usage = 0;
gpu_ram = 0;
flops = gstate.host_info.p_fpops;
strcpy(cmdline, "");
strcpy(file_prefix, "");
needs_network = false;
app = NULL;
project = NULL;
flops = gstate.host_info.p_fpops;
ref_cnt = 0;
strcpy(graphics_exec_path,"");
strcpy(graphics_exec_file, "");
max_working_set_size = 0;
missing_coproc = false;
missing_coproc_usage = 0.0;
strcpy(missing_coproc_name, "");
dont_throttle = false;
is_wrapper = false;
needs_network = false;
is_vm_app = false;
is_wrapper = false;
index = 0;
#ifdef SIM
dont_use = false;
#endif
}
int APP_VERSION::parse(XML_PARSER& xp) {
......
......@@ -72,7 +72,9 @@ struct URL_LIST {
int start_index;
int current_index;
URL_LIST(){};
URL_LIST() {
clear();
}
void clear() {
urls.clear();
......@@ -326,7 +328,9 @@ struct APP_VERSION {
bool dont_use;
#endif
APP_VERSION(){}
APP_VERSION() {
init();
}
~APP_VERSION(){}
void init();
int parse(XML_PARSER&);
......@@ -362,7 +366,20 @@ struct WORKUNIT {
double rsc_memory_bound;
double rsc_disk_bound;
WORKUNIT(){}
WORKUNIT(){
strcpy(name, "");
strcpy(app_name, "");
version_num = 0;
command_line = "";
input_files.clear();
project = NULL;
app = NULL;
ref_cnt = 0;
rsc_fpops_est = 0.0;
rsc_fpops_bound = 0.0;
rsc_memory_bound = 0.0;
rsc_disk_bound = 0.0;
}
~WORKUNIT(){}
int parse(XML_PARSER&);
int write(MIOFILE&);
......
......@@ -546,14 +546,23 @@ int CLIENT_STATE::add_project(
project->attached_via_acct_mgr = attached_via_acct_mgr;
retval = project->write_account_file();
if (retval) return retval;
if (retval) {
delete project;
return retval;
}
get_account_filename(canonical_master_url, path);
f = boinc_fopen(path, "r");
if (!f) return ERR_FOPEN;
if (!f) {
delete project;
return ERR_FOPEN;
}
retval = project->parse_account(f);
fclose(f);
if (retval) return retval;
if (retval) {
delete project;
return retval;
}
// remove any old files
// (unless PROJECT/app_info.xml is found, so that
......@@ -572,7 +581,10 @@ int CLIENT_STATE::add_project(
}
retval = make_project_dir(*project);
if (retval) return retval;
if (retval) {
delete project;
return retval;
}
projects.push_back(project);
sort_projects_by_name();
project->sched_rpc_pending = RPC_REASON_INIT;
......
......@@ -762,6 +762,7 @@ void RSS_FEED::delete_files() {
RSS_FEED_OP::RSS_FEED_OP() {
error_num = BOINC_SUCCESS;
rfp = NULL;
gui_http = &gstate.gui_http;
}
......
......@@ -43,6 +43,8 @@ FILE_XFER::FILE_XFER() {
strcpy(pathname, "");
strcpy(header, "");
file_size_query = false;
is_upload = false;
starting_size = 0.0;
}
FILE_XFER::~FILE_XFER() {
......
......@@ -334,6 +334,7 @@ int COPROCS::add_other_coproc_types() {
c.opencl_device_indexes[0] = c.opencl_prop.opencl_device_index;
c.opencl_device_ids[0] = c.opencl_prop.device_id;
c.instance_has_opencl[0] = true;
c.clear_usage();
safe_strcpy(c.type, other_opencls[i].name);
// Don't call COPROCS::add() because duplicate type is legal here
......
......@@ -60,7 +60,7 @@ struct GUI_HTTP {
struct GUI_HTTP_OP* gui_http_op;
HTTP_OP http_op;
GUI_HTTP(): gui_http_state(GUI_HTTP_STATE_IDLE) {}
GUI_HTTP(): gui_http_state(GUI_HTTP_STATE_IDLE), gui_http_op(NULL) {}
int do_rpc(
GUI_HTTP_OP*, const char* url, const char* output_file,
bool is_background
......@@ -85,7 +85,7 @@ struct GUI_HTTP {
struct GUI_HTTP_OP {
GUI_HTTP* gui_http;
virtual void handle_reply(int) {}
GUI_HTTP_OP(){}
GUI_HTTP_OP(): gui_http(NULL) {}
virtual ~GUI_HTTP_OP(){}
};
......
......@@ -78,14 +78,19 @@ GUI_RPC_CONN::GUI_RPC_CONN(int s) :
{
sock = s;
mfout.init_mfile(&mout);
strcpy(request_msg,"");
request_nbytes = 0;
strcpy(nonce,"");
auth_needed = false;
au_ss_state = AU_SS_INIT;
au_mgr_state = AU_MGR_INIT;
got_auth1 = false;
got_auth2 = false;
sent_unauthorized = false;
is_local = false;
quit_flag = false;
au_ss_state = AU_SS_INIT;
au_mgr_state = AU_MGR_INIT;
notice_refresh = false;
request_nbytes = 0;
}
GUI_RPC_CONN::~GUI_RPC_CONN() {
......@@ -93,8 +98,10 @@ GUI_RPC_CONN::~GUI_RPC_CONN() {
}
GUI_RPC_CONN_SET::GUI_RPC_CONN_SET() {
remote_hosts_file_exists = false;
lsock = -1;
time_of_last_rpc_needing_network = 0;
strcpy(password,"");
}
bool GUI_RPC_CONN_SET::poll() {
......
......@@ -236,6 +236,7 @@ void HTTP_OP::init(PROJECT* p) {
void HTTP_OP::reset() {
req1 = NULL;
req1_len = 0;
strcpy(infile, "");
strcpy(outfile, "");
strcpy(error_msg, "");
......@@ -246,7 +247,10 @@ void HTTP_OP::reset() {
fileIn = NULL;
fileOut = NULL;
connect_error = 0;
response = 0;
start_time = 0;
bytes_xferred = 0;
start_bytes_xferred = 0;
bSentHeader = false;
project = 0;
close_socket();
......@@ -256,6 +260,7 @@ void HTTP_OP::reset() {
HTTP_OP::HTTP_OP() {
strcpy(m_url, "");
strcpy(m_curl_ca_bundle_location, "");
strcpy(m_curl_user_credentials, "");
content_length = 0;
file_offset = 0;
strcpy(request_header, "");
......
......@@ -72,12 +72,22 @@ void RESULT::clear() {
suspended_via_gui = false;
coproc_missing = false;
report_immediately = false;
rr_sim_misses_deadline = false;
not_started = false;
name_md5 = "";
index = 0;
app = NULL;
wup = NULL;
project = NULL;
rrsim_flops_left = 0;
rrsim_finish_delay = 0;
rrsim_flops = 0;
rrsim_done = false;
already_selected = false;
rr_sim_misses_deadline = false;
unfinished_time_slice = false;
seqno = 0;
edf_scheduled = false;
strcpy(resources, "");
report_immediately = false;
schedule_backoff = 0;
strcpy(schedule_backoff_reason, "");
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment