diff --git a/api/graphics2_win.cpp b/api/graphics2_win.cpp index 63f29898e81..4cb1af4a3c5 100644 --- a/api/graphics2_win.cpp +++ b/api/graphics2_win.cpp @@ -71,7 +71,7 @@ void boinc_close_window_and_quit(const char* p) { } } -void SetupPixelFormat(HDC win_dc) { +void SetupPixelFormat(HDC dc) { int nPixelFormat; char buf[256]; @@ -98,11 +98,11 @@ void SetupPixelFormat(HDC win_dc) { // chooses the best pixel format // - nPixelFormat = ChoosePixelFormat(win_dc, &pfd); + nPixelFormat = ChoosePixelFormat(dc, &pfd); // set pixel format to device context. // - if (!SetPixelFormat(win_dc, nPixelFormat, &pfd)) { + if (!SetPixelFormat(dc, nPixelFormat, &pfd)) { fprintf(stderr, "%s ERROR: Couldn't set pixel format for device context (0x%x).\n", boinc_msg_prefix(buf, sizeof(buf)), GetLastError() @@ -468,14 +468,14 @@ void boinc_set_windows_icon(const char* icon16, const char* icon48) { LONGLONG ic; HWND hWnd = FindWindow("BOINC_app",NULL); - if (ic = (LONGLONG)LoadIcon(instance, icon48)) { + if ((ic = (LONGLONG)LoadIcon(instance, icon48)) != 0) { #ifdef _WIN64 SetClassLongPtr(hWnd, GCLP_HICON, (LONG_PTR)ic); #else SetClassLongPtr(hWnd, GCLP_HICON, (LONG)ic); #endif } - if (ic = (LONGLONG)LoadImage(instance, icon16, IMAGE_ICON, 16, 16, 0)) { + if ((ic = (LONGLONG)LoadImage(instance, icon16, IMAGE_ICON, 16, 16, 0)) != 0) { #ifdef _WIN64 SetClassLongPtr(hWnd, GCLP_HICONSM, (LONG_PTR)ic); #else diff --git a/api/gutil.cpp b/api/gutil.cpp index 6cd12099a58..ad4a5d8e8a6 100644 --- a/api/gutil.cpp +++ b/api/gutil.cpp @@ -626,8 +626,8 @@ void DecodeJPG(jpeg_decompress_struct* cinfo, tImageJPG *pImageData) { } struct my_error_mgr { - struct jpeg_error_mgr pub; jmp_buf setjmp_buffer; + struct jpeg_error_mgr pub; }; typedef struct my_error_mgr * my_error_ptr; diff --git a/client/boinc_cmd.cpp b/client/boinc_cmd.cpp index 30250725ab5..93f2ec3cd27 100644 --- a/client/boinc_cmd.cpp +++ b/client/boinc_cmd.cpp @@ -122,7 +122,6 @@ char* next_arg(int argc, char** argv, int& i) { if (i >= argc) { fprintf(stderr, "Missing command-line argument\n"); usage(); - exit(1); } return argv[i++]; } @@ -212,7 +211,7 @@ void show_str_lists(vector &lines, size_t ncols) { for (const STR_LIST& s: lines) { max = std::max(max, strlen(s[i])); } - lengths.push_back(max); + lengths.push_back(static_cast(max)); } for (const STR_LIST &line : lines) { for (i=0; iproject->project_name.c_str()); - y -= .02; + y -= .02f; float prog_pos[] = {x, y, 0}; - float prog_c[] = {.5, .4, .1, alpha/2}; - float prog_ci[] = {.1, .8, .2, alpha}; - progress.init(prog_pos, .4, -.01, -0.008, prog_c, prog_ci); + float prog_c[] = {.5f, .4f, .1f, alpha/2}; + float prog_ci[] = {.1f, .8f, .2f, alpha}; + progress.init(prog_pos, .4f, -.01f, -0.008f, prog_c, prog_ci); progress.draw(r->fraction_done); snprintf(buf, sizeof(buf), "%.2f%% ", r->fraction_done*100); ttf_render_string(x+.41, y, 0, TASK_INFO_SIZE, white, buf); - y -= .03; - x += .05; + y -= .03f; + x += .05f; snprintf(buf, sizeof(buf), "Elapsed: %.0f sec Remaining: %.0f sec", r->elapsed_time, r->estimated_cpu_time_remaining); ttf_render_string(x, y, 0, TASK_INFO_SIZE, white, buf); - y -= .03; + y -= .03f; snprintf(buf, sizeof(buf), "App: %s Task: %s", r->app->user_friendly_name, r->wup->name); ttf_render_string(x, y, 0, TASK_INFO_SIZE, white, buf); - y -= .03; + y -= .03f; } #if 0 @@ -224,44 +224,44 @@ void show_coords() { #endif void show_project(unsigned int index, float /*alpha*/) { - float x=.2, y=.6; + float x=.2f, y=.6f; char buf[1024]; ttf_render_string(x, y, 0, PROJ_INTRO_SIZE, white, "This computer is participating in"); - y -= .07; + y -= .07f; PROJECT *p = cc_state.projects[index]; ttf_render_string(x, y, 0, PROJ_NAME_SIZE, white, (char*)p->project_name.c_str()); - y -= .07; + y -= .07f; ttf_render_string(x, y, 0, PROJ_INFO_SIZE, white, p->master_url); - y -= .05; + y -= .05f; snprintf(buf, sizeof(buf), "User: %s", p->user_name.c_str()); ttf_render_string(x, y, 0, PROJ_INFO_SIZE, white, buf); - y -= .05; + y -= .05f; if (p->team_name.size()) { snprintf(buf, sizeof(buf), "Team: %s", p->team_name.c_str()); ttf_render_string(x, y, 0, PROJ_INFO_SIZE, white, buf); - y -= .05; + y -= .05f; } snprintf(buf, sizeof(buf), "Total credit: %.0f Average credit: %.0f", p->user_total_credit, p->user_expavg_credit); ttf_render_string(x, y, 0, PROJ_INFO_SIZE, white, buf); - y -= .05; + y -= .05f; if (p->suspended_via_gui) { ttf_render_string(x, y, 0, PROJ_INFO_SIZE, white, "Suspended"); } } void show_disconnected() { - float x=.3, y=.3; + float x=.3f, y=.3f; char buf[256]; snprintf(buf, sizeof(buf), "%s is not running.", brand_name); ttf_render_string(x, y, 0, ALERT_SIZE, white, buf); } void show_no_projects() { - float x=.2, y=.3; + float x=.2f, y=.3f; char buf[256]; snprintf(buf, sizeof(buf), "%s is not attached to any projects.", brand_name); ttf_render_string(x, y, 0, ALERT_SIZE, white, buf); - y = .25; + y = .25f; snprintf(buf, sizeof(buf), "Attach to projects using %s.", brand_name); ttf_render_string(x, y, 0, ALERT_SIZE, white, buf); } @@ -271,7 +271,7 @@ void show_no_projects() { // index is where to start looking in job array // void show_jobs(unsigned int index, double alpha) { - float x=.1, y=.7; + float x=.1f, y=.7f; unsigned int nfound = 0; unsigned int i; cc_status.task_suspend_reason &= ~SUSPEND_REASON_CPU_THROTTLE; @@ -285,16 +285,16 @@ void show_jobs(unsigned int index, double alpha) { if (r->scheduler_state != CPU_SCHED_SCHEDULED) continue; if (!nfound) { ttf_render_string(x, y, 0, TASK_INTRO_SIZE, white, "Running tasks:"); - y -= .05; + y -= .05f; } show_result(r, x, y, alpha); - y -= .05; + y -= .05f; nfound++; if (nfound == MAX_JOBS_DISPLAY) break; } } if (!nfound) { - y = .5; + y = .5f; ttf_render_string(x, y, 0, TASK_NONE_SIZE, white, "No running tasks"); char *p = 0; switch (cc_status.task_suspend_reason) { @@ -324,7 +324,7 @@ void show_jobs(unsigned int index, double alpha) { p = "Computing suspended because processor usage is high"; break; } if (p) { - y -= .1; + y -= .1f; ttf_render_string(x, y, 0, TASK_NONE_REASON_SIZE, white, p); } } @@ -382,7 +382,7 @@ void app_graphics_render(int , int , double t) { double alpha; static bool showing_project = false; static unsigned int project_index = 0, job_index=0; - static float logo_pos[3] = {.2, .2, 0}; + static float logo_pos[3] = {.2f, .2f, 0}; int retval; if (!connected) { diff --git a/lib/common_defs.h b/lib/common_defs.h index c5cbcb6a71f..472cf4f96c4 100644 --- a/lib/common_defs.h +++ b/lib/common_defs.h @@ -395,7 +395,7 @@ struct DEVICE_STATUS { battery_temperature_celsius = 0; wifi_online = false; user_active = false; - strcpy(device_name, ""); + strncpy(device_name, "", sizeof(device_name)); } }; diff --git a/lib/crypt_prog.cpp b/lib/crypt_prog.cpp index 5e4d5878b08..d9b872dd6a7 100644 --- a/lib/crypt_prog.cpp +++ b/lib/crypt_prog.cpp @@ -86,7 +86,7 @@ void usage() { } unsigned int random_int() { - unsigned int n; + unsigned int n = 0; #if defined(_WIN32) #if defined(__CYGWIN32__) HMODULE hLib=LoadLibrary((const char *)"ADVAPI32.DLL"); @@ -238,8 +238,8 @@ int main(int argc, char** argv) { if (retval) die("read_public_key"); f = fopen(argv[3], "r"); if (!f) die("fopen"); - int n = fread(cbuf, 1, 256, f); - cbuf[n] = 0; + size_t k = fread(cbuf, 1, 256, f); + cbuf[k] = 0; retval = check_string_signature(argv[2], cbuf, public_key, is_valid); if (retval) die("check_string_signature"); @@ -264,7 +264,7 @@ int main(int argc, char** argv) { if (retval) die("read_public_key"); strcpy((char*)buf2, "encryption test successful"); in.data = buf2; - in.len = strlen((char*)in.data); + in.len = static_cast(strlen((char*)in.data)); out.data = buf; encrypt_private(private_key, in, out); in = out; diff --git a/samples/example_app/slide_show.cpp b/samples/example_app/slide_show.cpp index 913388d8254..2a76d12dc7c 100644 --- a/samples/example_app/slide_show.cpp +++ b/samples/example_app/slide_show.cpp @@ -51,7 +51,7 @@ APP_INIT_DATA uc_aid; bool mouse_down = false; int mouse_x, mouse_y; double pitch_angle, roll_angle, viewpoint_distance=10; -float color[4] = {.7, .2, .5, 1}; +float color[4] = {.7f, .2f, .5f, 1}; // the color of the 3D object. // Can be changed using preferences UC_SHMEM* shmem = NULL; @@ -143,8 +143,8 @@ static void init_lights() { static void draw_logo() { if (logo.present) { - float pos[3] = {.2, .3, 0}; - float size[3] = {.6, .4, 0}; + float pos[3] = {.2f, .3f, 0}; + float size[3] = {.6f, .4f, 0}; logo.draw(pos, size, ALIGN_CENTER, ALIGN_CENTER); } } @@ -177,7 +177,7 @@ static void init_camera(double dist) { set_viewpoint(dist); } -void app_graphics_render(int xs, int ys, double time_of_day) { +void app_graphics_render(int, int, double) { // boinc_graphics_get_shmem() must be called after // boinc_parse_init_data_file() // Put this in the main loop to allow retries if the @@ -212,12 +212,9 @@ void app_graphics_resize(int w, int h){ // mouse drag w/ left button rotates 3D objects; // mouse draw w/ right button zooms 3D objects // -void boinc_app_mouse_move(int x, int y, int left, int middle, int right) { +void boinc_app_mouse_move(int, int, int, int, int){} -} - -void boinc_app_mouse_button(int x, int y, int which, int is_down) { -} +void boinc_app_mouse_button(int, int, int, int){} void boinc_app_key_press(int, int){} diff --git a/samples/example_app/uc2.cpp b/samples/example_app/uc2.cpp index b2e2119714a..ae347d3729d 100644 --- a/samples/example_app/uc2.cpp +++ b/samples/example_app/uc2.cpp @@ -141,7 +141,7 @@ void update_shmem() { int main(int argc, char **argv) { int i; - int c, nchars = 0, retval, n; + int c, nchars = 0, retval, n = 0; double fsize, fd; char input_path[512], output_path[512], chkpt_path[512], buf[256]; MFILE out; diff --git a/samples/example_app/uc2_graphics.cpp b/samples/example_app/uc2_graphics.cpp index 72fa33ee775..c2c8acb3efb 100644 --- a/samples/example_app/uc2_graphics.cpp +++ b/samples/example_app/uc2_graphics.cpp @@ -61,7 +61,7 @@ APP_INIT_DATA uc_aid; bool mouse_down = false; int mouse_x, mouse_y; double pitch_angle, roll_angle, viewpoint_distance=10; -float color[4] = {.7, .2, .5, 1}; +float color[4] = {.7f, .2f, .5f, 1}; // the color of the 3D object. // Can be changed using preferences UC_SHMEM* shmem = NULL; @@ -79,15 +79,15 @@ static void init_lights() { static void draw_logo() { if (logo.present) { - float pos[3] = {.2, .3, 0}; - float size[3] = {.6, .4, 0}; + float pos[3] = {.2f, .3f, 0}; + float size[3] = {.6f, .4f, 0}; logo.draw(pos, size, ALIGN_CENTER, ALIGN_CENTER); } } static void draw_text() { static float x=0, y=0; - static float dx=0.0003, dy=0.0007; + static float dx=0.0003f, dy=0.0007f; char buf[256]; x += dx; y += dy; @@ -122,7 +122,7 @@ static void draw_text() { static void draw_3d_stuff() { static float x=0, y=0, z=10; - static float dx=0.3, dy=0.2, dz=0.5; + static float dx=0.3f, dy=0.2f, dz=0.5f; x += dx; y += dy; z += dz; @@ -165,7 +165,7 @@ static void init_camera(double dist) { set_viewpoint(dist); } -void app_graphics_render(int xs, int ys, double time_of_day) { +void app_graphics_render(int, int, double) { // boinc_graphics_get_shmem() must be called after // boinc_parse_init_data_file() // Put this in the main loop to allow retries if the @@ -211,7 +211,7 @@ void app_graphics_resize(int w, int h){ // mouse drag w/ left button rotates 3D objects; // mouse draw w/ right button zooms 3D objects // -void boinc_app_mouse_move(int x, int y, int left, int middle, int right) { +void boinc_app_mouse_move(int x, int y, int left, int, int right) { if (left) { pitch_angle += (y-mouse_y)*.1; roll_angle += (x-mouse_x)*.1; @@ -227,7 +227,7 @@ void boinc_app_mouse_move(int x, int y, int left, int middle, int right) { } } -void boinc_app_mouse_button(int x, int y, int which, int is_down) { +void boinc_app_mouse_button(int x, int y, int, int is_down) { if (is_down) { mouse_down = true; mouse_x = x; diff --git a/samples/nvcuda/cuda.cpp b/samples/nvcuda/cuda.cpp index abcc717f35d..c15a9b8125d 100644 --- a/samples/nvcuda/cuda.cpp +++ b/samples/nvcuda/cuda.cpp @@ -111,7 +111,7 @@ int main(int argc, char** argv) { printf("Last inversion # is : %d\n",lastInversion); fscanf(state,"%d",&dimension); cudaMallocHost((void **)&h_idata,dimension*dimension*sizeof(REAL)); - for (int i=0;i cpu_time) break; fd = .5 + .5*(e/cpu_time); diff --git a/samples/openclapp/openclapp.cpp b/samples/openclapp/openclapp.cpp index afe6e51ab58..ed0b08e9d10 100644 --- a/samples/openclapp/openclapp.cpp +++ b/samples/openclapp/openclapp.cpp @@ -161,7 +161,7 @@ int main(int argc, char * argv[]) { print_to_file(&out,input,matrixSize); - for (int i=lastInversion+1;i<=NUM_ITERATIONS;++i) { + for (i=lastInversion+1;i<=NUM_ITERATIONS;++i) { //the invert function will trigger kernel calls. invert(input,output,matrixSize); printf("Finish inversion #%d\n",i); @@ -225,7 +225,7 @@ int main(int argc, char * argv[]) { if (cpu_time) { printf("\nBurning up some CPU time ... \n"); double start = dtime(); - for (int i=0; ; i++) { + for (i=0; ; i++) { double e = dtime()-start; if (e > cpu_time) break; fd = .5 + .5*(e/cpu_time); @@ -273,7 +273,7 @@ static double do_a_giga_flop(int foo) { } /* Save the computation state into checkpoint file */ -int do_checkpoint(MFILE& mf, int n, cl_float *input, int matrixSize) { +int do_checkpoint(MFILE& mf, int n, cl_float *in, int matrixSize) { int retval; string resolved_name; @@ -285,7 +285,7 @@ int do_checkpoint(MFILE& mf, int n, cl_float *input, int matrixSize) { fprintf(f, " "); for (int i=0;i(strlen(buf))); } last = ac_state; } else { diff --git a/samples/worker/worker.cpp b/samples/worker/worker.cpp index dea13554299..77f591d56f8 100644 --- a/samples/worker/worker.cpp +++ b/samples/worker/worker.cpp @@ -165,7 +165,7 @@ int parse_command_line(char* p, char** argv) { return argc; } -int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR Args, int) { +int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { LPSTR command_line; char* argv[100]; int argc; diff --git a/samples/wrappture/wrappture.cpp b/samples/wrappture/wrappture.cpp index 291ac5651b8..654c3ec186e 100644 --- a/samples/wrappture/wrappture.cpp +++ b/samples/wrappture/wrappture.cpp @@ -338,7 +338,7 @@ bool TASK::poll(int& status) { void TASK::kill() { #ifdef _WIN32 - TerminateProcess(pid_handle, -1); + TerminateProcess(pid_handle, static_cast(-1)); #else ::kill(pid, SIGKILL); #endif @@ -408,12 +408,12 @@ double TASK::cpu_time() { } void send_status_message( - TASK& task, double frac_done, double checkpoint_cpu_time + TASK& task, double frac_done, double checkpoint_cpu_time_value ) { double current_cpu_time = task.starting_cpu + task.cpu_time(); boinc_report_app_status( current_cpu_time, - checkpoint_cpu_time, + checkpoint_cpu_time_value, frac_done ); } diff --git a/samples/wrappture/wrappture_example.cpp b/samples/wrappture/wrappture_example.cpp index 69f6c77e9df..69bc7a58464 100644 --- a/samples/wrappture/wrappture_example.cpp +++ b/samples/wrappture/wrappture_example.cpp @@ -26,7 +26,7 @@ #include "filesys.h" #include "wrappture.h" -int main(int argc, char * argv[]) { +int main(int, char**) { char buf[256]; RpLibrary* lib = NULL; @@ -40,7 +40,6 @@ int main(int argc, char * argv[]) { double kT = 0.0; double Emin = 0.0; double Emax = 0.0; - double f = 0.0; int err = 0; @@ -119,7 +118,7 @@ int main(int argc, char * argv[]) { #ifdef _WIN32 -int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR Args, int WinMode) { +int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { LPSTR command_line; char* argv[100]; int argc; diff --git a/tests/unit-tests/lib/test_parse.cpp b/tests/unit-tests/lib/test_parse.cpp index a0134d5eab2..86b75a024da 100644 --- a/tests/unit-tests/lib/test_parse.cpp +++ b/tests/unit-tests/lib/test_parse.cpp @@ -85,7 +85,7 @@ namespace test_parse { int expects = 0; char name[64]; - strcpy(name, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); + strncpy(name, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", sizeof(name)); int val; diff --git a/tests/unit-tests/lib/test_str_util.cpp b/tests/unit-tests/lib/test_str_util.cpp index f50e572956c..67c288944dd 100644 --- a/tests/unit-tests/lib/test_str_util.cpp +++ b/tests/unit-tests/lib/test_str_util.cpp @@ -122,7 +122,7 @@ namespace test_str_util { char* argv[100]; int ret; char *nilbuf {0}; - sprintf(buf, "one two three"); + snprintf(buf, sizeof(buf), "one two three"); ret = parse_command_line(buf, argv); EXPECT_EQ(ret, 3); EXPECT_STREQ(argv[0], "one"); @@ -130,7 +130,7 @@ namespace test_str_util { EXPECT_STREQ(argv[2], "three"); EXPECT_STREQ(argv[3], nilbuf); EXPECT_STREQ(buf, "one"); - sprintf(buf, "four \'five\' \"six\""); + snprintf(buf, sizeof(buf), "four \'five\' \"six\""); ret = parse_command_line(buf, argv); EXPECT_EQ(ret, 3); EXPECT_STREQ(argv[0], "four"); @@ -138,7 +138,7 @@ namespace test_str_util { EXPECT_STREQ(argv[2], "six"); EXPECT_STREQ(argv[3], nilbuf); EXPECT_STREQ(buf, "four"); - sprintf(buf, "seven \'eig ht\' \"ni ne\""); + snprintf(buf, sizeof(buf), "seven \'eig ht\' \"ni ne\""); ret = parse_command_line(buf, argv); EXPECT_EQ(ret, 3); EXPECT_STREQ(argv[0], "seven"); @@ -146,7 +146,7 @@ namespace test_str_util { EXPECT_STREQ(argv[2], "ni ne"); EXPECT_STREQ(argv[3], nilbuf); EXPECT_STREQ(buf, "seven"); - sprintf(buf, "tän \'elèv én\' \"tŵelv e\""); + snprintf(buf, sizeof(buf), "tän \'elèv én\' \"tŵelv e\""); ret = parse_command_line(buf, argv); EXPECT_EQ(ret, 3); EXPECT_STREQ(argv[0], "tän"); @@ -155,7 +155,7 @@ namespace test_str_util { EXPECT_STREQ(argv[3], nilbuf); EXPECT_STREQ(buf, "tän"); // function doesn't check syntax so this works too - sprintf(buf, "13\" \'\"4teen\'\" "); + snprintf(buf, sizeof(buf), "13\" \'\"4teen\'\" "); ret = parse_command_line(buf, argv); EXPECT_EQ(ret, 3); EXPECT_STREQ(argv[0], "13\""); @@ -287,10 +287,10 @@ namespace test_str_util { char buf[256] = "_(\"The quick brown fox jumps over the lazy dog\")"; strip_translation(buf); EXPECT_STREQ(buf, "The quick brown fox jumps over the lazy dog"); - sprintf(buf, "The _(\"quick brown\") fox jumps over the _(\"lazy\") dog"); + snprintf(buf, sizeof(buf), "The _(\"quick brown\") fox jumps over the _(\"lazy\") dog"); strip_translation(buf); EXPECT_STREQ(buf, "The quick brown fox jumps over the lazy dog"); - sprintf(buf, "The _\"quick brown\" ) fox jumps over the (_\"lazy\") dog"); + snprintf(buf, sizeof(buf), "The _\"quick brown\" ) fox jumps over the (_\"lazy\") dog"); strip_translation(buf); EXPECT_STREQ(buf, "The _\"quick brown\" ) fox jumps over the (_\"lazy dog"); } @@ -314,47 +314,47 @@ namespace test_str_util { EXPECT_STREQ(buf1, "[BOINC|1.2.3]"); EXPECT_STREQ(buf2, ""); EXPECT_STREQ(buf3, ""); - strcpy(buf, "[BOINC|1.2.3][vbox|4.5.6abc]"); + strncpy(buf, "[BOINC|1.2.3][vbox|4.5.6abc]", sizeof(buf)); parse_serialnum(buf, buf1, buf2, buf3); EXPECT_STREQ(buf1, "[BOINC|1.2.3]"); EXPECT_STREQ(buf2, "[vbox|4.5.6abc]"); EXPECT_STREQ(buf3, ""); - strcpy(buf, "[BOINC|1.2.3][INTEL|Intel(R) HD Graphics|1|2406MB||201]"); + strncpy(buf, "[BOINC|1.2.3][INTEL|Intel(R) HD Graphics|1|2406MB||201]", sizeof(buf)); parse_serialnum(buf, buf1, buf2, buf3); EXPECT_STREQ(buf1, "[BOINC|1.2.3]"); EXPECT_STREQ(buf2, ""); EXPECT_STREQ(buf3, "[INTEL|Intel(R) HD Graphics|1|2406MB||201]"); - strcpy(buf, "[vbox|4.5.6abc][INTEL|Intel(R) HD Graphics|1|2406MB||201][BOINC|1.2.3]"); + strncpy(buf, "[vbox|4.5.6abc][INTEL|Intel(R) HD Graphics|1|2406MB||201][BOINC|1.2.3]", sizeof(buf)); parse_serialnum(buf, buf1, buf2, buf3); EXPECT_STREQ(buf1, "[BOINC|1.2.3]"); EXPECT_STREQ(buf2, "[vbox|4.5.6abc]"); EXPECT_STREQ(buf3, "[INTEL|Intel(R) HD Graphics|1|2406MB||201]"); - strcpy(buf, "[BOINC|1.2.3][INTEL|Intel(R) HD Graphics|1|2406MB||201][vbox|4.5.6abc]"); + strncpy(buf, "[BOINC|1.2.3][INTEL|Intel(R) HD Graphics|1|2406MB||201][vbox|4.5.6abc]", sizeof(buf)); parse_serialnum(buf, buf1, buf2, buf3); EXPECT_STREQ(buf1, "[BOINC|1.2.3]"); EXPECT_STREQ(buf2, "[vbox|4.5.6abc]"); EXPECT_STREQ(buf3, "[INTEL|Intel(R) HD Graphics|1|2406MB||201]"); - strcpy(buf, "[BOINC|1.2.3][vbox|4.5.6abc][INTEL|Intel(R) HD Graphics|1|2406MB||201]"); + strncpy(buf, "[BOINC|1.2.3][vbox|4.5.6abc][INTEL|Intel(R) HD Graphics|1|2406MB||201]", sizeof(buf)); parse_serialnum(buf, buf1, buf2, buf3); EXPECT_STREQ(buf1, "[BOINC|1.2.3]"); EXPECT_STREQ(buf2, "[vbox|4.5.6abc]"); EXPECT_STREQ(buf3, "[INTEL|Intel(R) HD Graphics|1|2406MB||201]"); - strcpy(buf, "[BOINC|7.6.22][CAL|ATI Radeon HD 5800/5900 series (Cypress/Hemlock)|2|1024MB|1.4.1848|102][vbox|5.1.26]"); + strncpy(buf, "[BOINC|7.6.22][CAL|ATI Radeon HD 5800/5900 series (Cypress/Hemlock)|2|1024MB|1.4.1848|102][vbox|5.1.26]", sizeof(buf)); parse_serialnum(buf, buf1, buf2, buf3); EXPECT_STREQ(buf1, "[BOINC|7.6.22]"); EXPECT_STREQ(buf2, "[vbox|5.1.26]"); EXPECT_STREQ(buf3, "[CAL|ATI Radeon HD 5800/5900 series (Cypress/Hemlock)|2|1024MB|1.4.1848|102]"); - strcpy(buf, "[BOINC|7.6.22[CAL|ATI Radeon HD 5800/5900 series (Cypress/Hemlock)|2|1024MB|1.4.1848|102][vbox|5.1.26]"); + strncpy(buf, "[BOINC|7.6.22[CAL|ATI Radeon HD 5800/5900 series (Cypress/Hemlock)|2|1024MB|1.4.1848|102][vbox|5.1.26]", sizeof(buf)); parse_serialnum(buf, buf1, buf2, buf3); EXPECT_STREQ(buf1, "[BOINC|7.6.22[CAL|ATI Radeon HD 5800/5900 series (Cypress/Hemlock)|2|1024MB|1.4.1848|102]"); EXPECT_STREQ(buf2, "[vbox|5.1.26]"); EXPECT_STREQ(buf3, ""); - strcpy(buf, "[BOINC|7.6.22][CAL|ATI Radeon HD 5800/5900 series [Cypress/Hemlock]|2|1024MB|1.4.1848|102][vbox|5.1.26]"); + strncpy(buf, "[BOINC|7.6.22][CAL|ATI Radeon HD 5800/5900 series [Cypress/Hemlock]|2|1024MB|1.4.1848|102][vbox|5.1.26]", sizeof(buf)); parse_serialnum(buf, buf1, buf2, buf3); EXPECT_STREQ(buf1, "[BOINC|7.6.22]"); EXPECT_STREQ(buf2, ""); EXPECT_STREQ(buf3, "[CAL|ATI Radeon HD 5800/5900 series [Cypress/Hemlock]"); - strcpy(buf, "[BOINC|7.6.22][CAL|ATI Radeon HD 5800/5900 series (Cypress/Hemlock)|2|1024MB|1.4.1848|102][extra|7.8.9][vbox|5.1.26]"); + strncpy(buf, "[BOINC|7.6.22][CAL|ATI Radeon HD 5800/5900 series (Cypress/Hemlock)|2|1024MB|1.4.1848|102][extra|7.8.9][vbox|5.1.26]", sizeof(buf)); parse_serialnum(buf, buf1, buf2, buf3); EXPECT_STREQ(buf1, "[BOINC|7.6.22]"); EXPECT_STREQ(buf2, "[vbox|5.1.26]");