diff --git a/client/cs_apps.C b/client/cs_apps.C index 7a4de3dc29..c078a3c15a 100644 --- a/client/cs_apps.C +++ b/client/cs_apps.C @@ -84,10 +84,6 @@ bool CLIENT_STATE::handle_running_apps() { // locally, false otherwise // bool CLIENT_STATE::input_files_available(RESULT* rp) { - if(rp==NULL) { - fprintf(stderr, "error: CLIENT_STATE.input_files_available: unexpected NULL pointer rp\n"); - return false; - } WORKUNIT* wup = rp->wup; FILE_INFO* fip; unsigned int i; diff --git a/client/cs_scheduler.C b/client/cs_scheduler.C index b8bb76d7b1..8697ef591a 100644 --- a/client/cs_scheduler.C +++ b/client/cs_scheduler.C @@ -206,14 +206,7 @@ int CLIENT_STATE::make_scheduler_request(PROJECT* p, double work_req) { FILE* f = fopen(SCHED_OP_REQUEST_FILE, "wb"); unsigned int i; RESULT* rp; - if(p==NULL) { - fprintf(stderr, "error: CLIENT_STATE.make_scheduler_request: unexpected NULL pointer p\n"); - return ERR_NULL; - } - if(work_req<0) { - fprintf(stderr, "error: CLIENT_STATE.make_scheduler_request: negative work_req\n"); - return ERR_NEG; - } + if (!f) return ERR_FOPEN; fprintf(f, "\n" diff --git a/client/file_xfer.C b/client/file_xfer.C index 47cca052c2..fc12a6fc30 100644 --- a/client/file_xfer.C +++ b/client/file_xfer.C @@ -45,28 +45,12 @@ FILE_XFER::~FILE_XFER() { #if 0 // Is there any reason to keep this around? int FILE_XFER::init_download(char* url, char* outfile) { - if(url==NULL) { - fprintf(stderr, "error: FILE_XFER.init_download: unexpected NULL pointer url\n"); - return ERR_NULL; - } - if(outfile==NULL) { - fprintf(stderr, "error: FILE_XFER.init_download: unexpected NULL pointer outfile\n"); - return ERR_NULL; - } return HTTP_OP::init_get(url, outfile, file_size); } // Is there any reason to keep this around? int FILE_XFER::init_upload(char* url, char* infile) { - if(url==NULL) { - fprintf(stderr, "error: FILE_XFER.init_upload: unexpected NULL pointer url\n"); - return ERR_NULL; - } - if(outfile==NULL) { - fprintf(stderr, "error: FILE_XFER.init_upload: unexpected NULL pointer infile\n"); - return ERR_NULL; - } return HTTP_OP::init_put(url, infile); } #endif @@ -130,9 +114,6 @@ double FILE_XFER::elapsed_time() { // Create a new empty FILE_XFER_SET // FILE_XFER_SET::FILE_XFER_SET(HTTP_OP_SET* p) { - if(p==NULL) { - fprintf(stderr, "error: FILE_XFER_SET: unexpected NULL pointer p\n"); - } http_ops = p; } @@ -140,10 +121,7 @@ FILE_XFER_SET::FILE_XFER_SET(HTTP_OP_SET* p) { // int FILE_XFER_SET::insert(FILE_XFER* fxp) { int retval; - if(fxp==NULL) { - fprintf(stderr, "error: FILE_XFER_SET.insert: unexpected NULL pointer fxp\n"); - return ERR_NULL; - } + // record start time. // This could be made more accurate by omitting the connection // setup and initial request times. @@ -159,10 +137,7 @@ int FILE_XFER_SET::insert(FILE_XFER* fxp) { // int FILE_XFER_SET::remove(FILE_XFER* fxp) { vector::iterator iter; - if(fxp==NULL) { - fprintf(stderr, "error: FILE_XFER_SET.remove: unexpected NULL pointer fxp\n"); - return ERR_NULL; - } + http_ops->remove(fxp); iter = file_xfers.begin(); diff --git a/client/hostinfo.C b/client/hostinfo.C index 0081bdd30e..d8abae8edd 100644 --- a/client/hostinfo.C +++ b/client/hostinfo.C @@ -28,10 +28,7 @@ // int HOST_INFO::parse(FILE* in) { char buf[256]; - if(in==NULL) { - fprintf(stderr, "error: HOST_INFO.parse: unexpected NULL pointer in\n"); - return ERR_NULL; - } + memset(this, 0, sizeof(HOST_INFO)); while (fgets(buf, 256, in)) { if (match_tag(buf, "")) return 0; @@ -60,10 +57,6 @@ int HOST_INFO::parse(FILE* in) { // Write the host information, usually to the client state XML file // int HOST_INFO::write(FILE* out) { - if(out==NULL) { - fprintf(stderr, "error: HOST_INFO.write: unexpected NULL pointer out\n"); - return ERR_NULL; - } fprintf(out, "\n" " %d\n" diff --git a/client/http.C b/client/http.C index eb14275004..61dfa90c6c 100644 --- a/client/http.C +++ b/client/http.C @@ -48,15 +48,7 @@ static void parse_url(char* url, char* host, char* file) { char* p; char buf[256]; - if(url==NULL) { - fprintf(stderr, "error: parse_url: unexpected NULL pointer url\n"); - } - if(host==NULL) { - fprintf(stderr, "error: parse_url: unexpected NULL pointer host\n"); - } - if(file==NULL) { - fprintf(stderr, "error: parse_url: unexpected NULL pointer file\n"); - } + if (strncmp(url, "http://", 7) == 0) strcpy(buf, url+7); else strcpy(buf, url); p = strchr(buf, '/'); @@ -75,18 +67,6 @@ static void parse_url(char* url, char* host, char* file) { static void http_get_request_header( char* buf, char* host, char* file, double offset ) { - if(buf==NULL) { - fprintf(stderr, "error: http_get_request_header: unexpected NULL pointer buf\n"); - } - if(host==NULL) { - fprintf(stderr, "error: http_get_request_header: unexpected NULL pointer host\n"); - } - if(file==NULL) { - fprintf(stderr, "error: http_get_request_header: unexpected NULL pointer file\n"); - } - if(offset<0) { - fprintf(stderr, "error: http_get_request_header: negative offset\n"); - } if (offset) { sprintf(buf, "GET /%s HTTP/1.1\015\012" @@ -115,15 +95,6 @@ static void http_get_request_header( // Prints an HTTP 1.1 HEAD request header into buf // static void http_head_request_header(char* buf, char* host, char* file) { - if(buf==NULL) { - fprintf(stderr, "error: http_head_request_header: unexpected NULL pointer buf\n"); - } - if(host==NULL) { - fprintf(stderr, "error: http_head_request_header: unexpected NULL pointer host\n"); - } - if(file==NULL) { - fprintf(stderr, "error: http_head_request_header: unexpected NULL pointer file\n"); - } sprintf(buf, "HEAD /%s HTTP/1.1\015\012" "User-Agent: BOINC client\015\012" @@ -141,18 +112,6 @@ static void http_head_request_header(char* buf, char* host, char* file) { static void http_post_request_header( char* buf, char* host, char* file, int size ) { - if(buf==NULL) { - fprintf(stderr, "error: http_post_request_header: unexpected NULL pointer buf\n"); - } - if(host==NULL) { - fprintf(stderr, "error: http_post_request_header: unexpected NULL pointer host\n"); - } - if(file==NULL) { - fprintf(stderr, "error: http_post_request_header: unexpected NULL pointer file\n"); - } - if(size<0) { - fprintf(stderr, "error: http_post_request_header: negative size\n"); - } sprintf(buf, "POST /%s HTTP/1.0\015\012" "Pragma: no-cache\015\012" @@ -172,21 +131,6 @@ static void http_post_request_header( void http_put_request_header( char* buf, char* host, char* file, int size, int offset ) { - if(buf==NULL) { - fprintf(stderr, "error: http_put_request_header: unexpected NULL pointer buf\n"); - } - if(host==NULL) { - fprintf(stderr, "error: http_put_request_header: unexpected NULL pointer host\n"); - } - if(file==NULL) { - fprintf(stderr, "error: http_put_request_header: unexpected NULL pointer file\n"); - } - if(size<0) { - fprintf(stderr, "error: http_put_request_header: negative size\n"); - } - if(offset<0) { - fprintf(stderr, "error: http_put_request_header: negative offset\n"); - } if (offset) { sprintf(buf, "PUT /%s HTTP/1.1\015\012" @@ -263,18 +207,6 @@ int read_http_reply_header(int socket, HTTP_REPLY_HEADER& header) { // static int read_reply(int socket, char* buf, int len) { int i, n; - if(socket<0) { - fprintf(stderr, "error: read_reply: negative socket\n"); - return ERR_NEG; - } - if(buf==NULL) { - fprintf(stderr, "error: read_reply: unexpected NULL pointer buf\n"); - return ERR_NULL; - } - if(len<0) { - fprintf(stderr, "error: read_reply: negative len\n"); - return ERR_NEG; - } for (i=0; iinsert(ho); if (retval) return retval; http_ops.push_back(ho); @@ -492,7 +380,7 @@ bool HTTP_OP_SET::poll() { case HTTP_OP_POST: //case HTTP_OP_PUT: htp->http_op_state = HTTP_STATE_REQUEST_BODY; - htp->file = fopen(htp->infile, "r"); + htp->file = fopen(htp->infile, "rb"); if (!htp->file) { fprintf(stderr, "HTTP_OP: no input file %s\n", htp->infile); htp->io_done = true; @@ -522,7 +410,7 @@ bool HTTP_OP_SET::poll() { // If there's a file we also want to send, then start transferring // it, otherwise, go on to the next step if (htp->infile && strlen(htp->infile) > 0) { - htp->file = fopen(htp->infile, "r"); + htp->file = fopen(htp->infile, "rb"); if (!htp->file) { fprintf(stderr, "HTTP_OP: no input2 file %s\n", htp->infile); htp->io_done = true; @@ -601,7 +489,7 @@ bool HTTP_OP_SET::poll() { // Append to a file if it already exists, otherwise // create a new one. init_get should have already // deleted the file if necessary - htp->file = fopen(htp->outfile, "a"); + htp->file = fopen(htp->outfile, "ab"); if (!htp->file) { fprintf(stderr, "HTTP_OP: can't open output file %s\n", @@ -654,10 +542,7 @@ bool HTTP_OP_SET::poll() { // int HTTP_OP_SET::remove(HTTP_OP* p) { vector::iterator iter; - if(p==NULL) { - fprintf(stderr, "error: HTTP_OP_SET.remove: unexpected NULL pointer p\n"); - return ERR_NULL; - } + net_xfers->remove(p); iter = http_ops.begin(); diff --git a/client/log_flags.C b/client/log_flags.C index a30d9b9847..026ceae378 100644 --- a/client/log_flags.C +++ b/client/log_flags.C @@ -38,10 +38,7 @@ LOG_FLAGS::LOG_FLAGS() { // int LOG_FLAGS::parse(FILE* in) { char buf[256]; - if(in==NULL) { - fprintf(stderr, "error: LOG_FLAGS.parse: unexpected NULL pointer in\n"); - return ERR_NULL; - } + fgets(buf, 256, in); if (!match_tag(buf, "")) return ERR_XML_PARSE; while (fgets(buf, 256, in)) { diff --git a/client/net_stats.C b/client/net_stats.C index 52a7942259..4675c24e6d 100644 --- a/client/net_stats.C +++ b/client/net_stats.C @@ -71,10 +71,6 @@ void NET_STATS::update(bool is_upload, double nbytes, double nsecs) { // Write XML based network statistics // int NET_STATS::write(FILE* out, bool to_server) { - if(out==NULL) { - fprintf(stderr, "error: NET_STATS.write: unexpected NULL pointer out\n"); - return ERR_NULL; - } fprintf(out, "\n" " %f\n" @@ -97,10 +93,7 @@ int NET_STATS::write(FILE* out, bool to_server) { // int NET_STATS::parse(FILE* in) { char buf[256]; - if(in==NULL) { - fprintf(stderr, "error: NET_STATS.parse: unexpected NULL pointer in\n"); - return ERR_NULL; - } + memset(this, 0, sizeof(NET_STATS)); while (fgets(buf, 256, in)) { if (match_tag(buf, "")) return 0; diff --git a/client/pers_file_xfer.C b/client/pers_file_xfer.C index 8441b08c06..3d1fc0c615 100644 --- a/client/pers_file_xfer.C +++ b/client/pers_file_xfer.C @@ -228,10 +228,7 @@ bool PERS_FILE_XFER::poll(unsigned int now) { // int PERS_FILE_XFER::parse(FILE* fin) { char buf[256]; - if(fin==NULL) { - fprintf(stderr, "error: PERS_FILE_XFER_SET.parse: unexpected NULL pointer fin\n"); - return ERR_NULL; - } + while (fgets(buf, 256, fin)) { if (match_tag(buf, "")) return 0; else if (parse_int(buf, "", nretry)) continue; @@ -245,10 +242,6 @@ int PERS_FILE_XFER::parse(FILE* fin) { // Write XML information about a particular persistent file transfer // int PERS_FILE_XFER::write(FILE* fout) { - if (fout==NULL) { - fprintf(stderr, "error: PERS_FILE_XFER_SET.write: unexpected NULL pointer fout\n"); - return ERR_NULL; - } fprintf(fout, " \n" " %d\n" @@ -261,9 +254,6 @@ int PERS_FILE_XFER::write(FILE* fout) { } PERS_FILE_XFER_SET::PERS_FILE_XFER_SET(FILE_XFER_SET* p) { - if(p==NULL) { - fprintf(stderr, "error: PERS_FILE_XFER_SET: unexpected NULL pointer p\n"); - } file_xfers = p; } diff --git a/client/time_stats.C b/client/time_stats.C index b879e0c3cd..a2b55a3552 100644 --- a/client/time_stats.C +++ b/client/time_stats.C @@ -106,10 +106,7 @@ int TIME_STATS::write(FILE* out, bool to_server) { // int TIME_STATS::parse(FILE* in) { char buf[256]; - if(in==NULL) { - fprintf(stderr, "error: TIME_STATS.parse: unexpected NULL pointer in\n"); - return ERR_NULL; - } + while (fgets(buf, 256, in)) { if (match_tag(buf, "")) return 0; else if (parse_int(buf, "", last_update)) continue;