Skip to content

Commit

Permalink
Merge pull request #5804 from BOINC/vko_fix_win_warnings
Browse files Browse the repository at this point in the history
[Windows] Fix several build warnings
  • Loading branch information
davidpanderson committed Sep 11, 2024
2 parents a2b61ad + 3be93da commit 2b3cd21
Show file tree
Hide file tree
Showing 18 changed files with 94 additions and 99 deletions.
10 changes: 5 additions & 5 deletions api/graphics2_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand All @@ -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()
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion api/gutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions client/boinc_cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++];
}
Expand Down Expand Up @@ -212,7 +211,7 @@ void show_str_lists(vector<STR_LIST> &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<int>(max));
}
for (const STR_LIST &line : lines) {
for (i=0; i<ncols; i++) {
Expand Down
2 changes: 1 addition & 1 deletion clientgui/common/wxPieCtrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ wxPieCtrl::wxPieCtrl(wxWindow * parent, wxWindowID id, wxPoint pos,
m_LabelColour = isDarkMode ? *wxWHITE : *wxBLACK;
m_LegendBackColour = isDarkMode ? wxColour(0, 0, 255) : wxColour(255,255,0);
m_TitleFont = *wxSWISS_FONT;
m_TitleFont.SetWeight(wxBOLD);
m_TitleFont.SetWeight(wxFONTWEIGHT_BOLD);
m_LabelFont = *wxSWISS_FONT;
m_legendHorBorder = 10;
m_LegendVerBorder = 10;
Expand Down
50 changes: 25 additions & 25 deletions clientscr/ss_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ static void init_lights() {

static void draw_logo(float* pos, float alpha) {
if (logo.present) {
float size[3] = {.6, .4, 0};
float size[3] = {.6f, .4f, 0};
logo.draw(pos, size, ALIGN_CENTER, ALIGN_CENTER, alpha);
}
}
Expand All @@ -188,22 +188,22 @@ void show_result(RESULT* r, float x, float& y, float alpha) {
PROGRESS_2D progress;
char buf[256];
ttf_render_string(x, y, 0, TASK_PROJ_SIZE, white, (char*)r->project->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
Expand All @@ -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);
}
Expand All @@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion lib/common_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
};

Expand Down
8 changes: 4 additions & 4 deletions lib/crypt_prog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand All @@ -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<unsigned int>(strlen((char*)in.data));
out.data = buf;
encrypt_private(private_key, in, out);
in = out;
Expand Down
15 changes: 6 additions & 9 deletions samples/example_app/slide_show.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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){}

Expand Down
2 changes: 1 addition & 1 deletion samples/example_app/uc2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
16 changes: 8 additions & 8 deletions samples/example_app/uc2_graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions samples/nvcuda/cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<dimension*dimension;++i) {
for (i=0;i<dimension*dimension;++i) {
fscanf(state, "%lf", &num);
h_idata[i] = num;
}
Expand Down Expand Up @@ -166,7 +166,7 @@ int main(int argc, char** argv) {
}
print_to_file(&out,h_idata,dimension);

for (int i=lastInversion+1;i<=NUM_ITERATIONS;++i) {
for (i=lastInversion+1;i<=NUM_ITERATIONS;++i) {
invert(h_idata,dimension);
printf("Finish inversion #%d\n",i);
if (run_slow) {
Expand Down Expand Up @@ -217,7 +217,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);
Expand Down
Loading

0 comments on commit 2b3cd21

Please sign in to comment.