Skip to content

Commit 7ad019a

Browse files
authored
Merge pull request #6822 from BOINC/dpa_for_lib
lib: use modern for() syntax
2 parents b566925 + a87f7fe commit 7ad019a

File tree

9 files changed

+204
-208
lines changed

9 files changed

+204
-208
lines changed

lib/app_ipc.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// This file is part of BOINC.
2-
// http://boinc.berkeley.edu
3-
// Copyright (C) 2008 University of California
2+
// https://boinc.berkeley.edu
3+
// Copyright (C) 2026 University of California
44
//
55
// BOINC is free software; you can redistribute it and/or modify it
66
// under the terms of the GNU Lesser General Public License
@@ -240,8 +240,8 @@ int write_init_data_file(FILE* f, APP_INIT_DATA& ai) {
240240
ai.proxy_info.write(mf);
241241
}
242242
ai.global_prefs.write(mf);
243-
for (unsigned int i=0; i<ai.app_files.size(); i++) {
244-
fprintf(f, "<app_file>%s</app_file>\n", ai.app_files[i].c_str());
243+
for (const string &s: ai.app_files) {
244+
fprintf(f, "<app_file>%s</app_file>\n", s.c_str());
245245
}
246246
fprintf(f, "</app_init_data>\n");
247247
return 0;

lib/cc_config.cpp

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// This file is part of BOINC.
22
// https://boinc.berkeley.edu
3-
// Copyright (C) 2024 University of California
3+
// Copyright (C) 2026 University of California
44
//
55
// BOINC is free software; you can redistribute it and/or modify it
66
// under the terms of the GNU Lesser General Public License
@@ -491,7 +491,7 @@ int CC_CONFIG::parse(XML_PARSER& xp, LOG_FLAGS& log_flags) {
491491
return ERR_XML_PARSE;
492492
}
493493

494-
void EXCLUDE_GPU::write(MIOFILE& out) {
494+
void EXCLUDE_GPU::write(MIOFILE& out) const {
495495
out.printf(
496496
" <exclude_gpu>\n"
497497
" <url>%s</url>\n"
@@ -536,10 +536,10 @@ int CC_CONFIG::write(MIOFILE& out, LOG_FLAGS& log_flags) {
536536
allow_remote_gui_rpc ? 1 : 0
537537
);
538538

539-
for (i=0; i<alt_platforms.size(); ++i) {
539+
for (const string &s: alt_platforms) {
540540
out.printf(
541541
" <alt_platform>%s</alt_platform>\n",
542-
alt_platforms[i].c_str()
542+
s.c_str()
543543
);
544544
}
545545

@@ -586,28 +586,28 @@ int CC_CONFIG::write(MIOFILE& out, LOG_FLAGS& log_flags) {
586586
dont_use_docker
587587
);
588588

589-
for (i=0; i<disallowed_wsls.size(); ++i) {
589+
for (const string &s: disallowed_wsls) {
590590
out.printf(
591591
" <disallowed_wsl>%s</disallowed_wsl>\n",
592-
disallowed_wsls[i].c_str()
592+
s.c_str()
593593
);
594594
}
595595

596-
for (i=0; i<exclude_gpus.size(); i++) {
597-
exclude_gpus[i].write(out);
596+
for (const EXCLUDE_GPU &e: exclude_gpus) {
597+
e.write(out);
598598
}
599599

600-
for (i=0; i<exclusive_apps.size(); ++i) {
600+
for (const string &s: exclusive_apps) {
601601
out.printf(
602602
" <exclusive_app>%s</exclusive_app>\n",
603-
exclusive_apps[i].c_str()
603+
s.c_str()
604604
);
605605
}
606606

607-
for (i=0; i<exclusive_gpu_apps.size(); ++i) {
607+
for (const string &s: exclusive_gpu_apps) {
608608
out.printf(
609609
" <exclusive_gpu_app>%s</exclusive_gpu_app>\n",
610-
exclusive_gpu_apps[i].c_str()
610+
s.c_str()
611611
);
612612
}
613613

@@ -632,24 +632,24 @@ int CC_CONFIG::write(MIOFILE& out, LOG_FLAGS& log_flags) {
632632
http_transfer_timeout_bps
633633
);
634634

635-
for (i=0; i<ignore_gpu_instance[PROC_TYPE_NVIDIA_GPU].size(); ++i) {
635+
for (int d: ignore_gpu_instance[PROC_TYPE_NVIDIA_GPU]) {
636636
out.printf(
637637
" <ignore_nvidia_dev>%d</ignore_nvidia_dev>\n",
638-
ignore_gpu_instance[PROC_TYPE_NVIDIA_GPU][i]
638+
d
639639
);
640640
}
641641

642-
for (i=0; i<ignore_gpu_instance[PROC_TYPE_AMD_GPU].size(); ++i) {
642+
for (int d: ignore_gpu_instance[PROC_TYPE_AMD_GPU]) {
643643
out.printf(
644644
" <ignore_ati_dev>%d</ignore_ati_dev>\n",
645-
ignore_gpu_instance[PROC_TYPE_AMD_GPU][i]
645+
d
646646
);
647647
}
648648

649-
for (i=0; i<ignore_gpu_instance[PROC_TYPE_INTEL_GPU].size(); ++i) {
649+
for (int d: ignore_gpu_instance[PROC_TYPE_INTEL_GPU]) {
650650
out.printf(
651651
" <ignore_intel_dev>%d</ignore_intel_dev>\n",
652-
ignore_gpu_instance[PROC_TYPE_INTEL_GPU][i]
652+
d
653653
);
654654
}
655655

@@ -904,8 +904,7 @@ void APP_CONFIGS::write(MIOFILE& out) {
904904
out.printf(
905905
"<app_config>\n"
906906
);
907-
for (unsigned int i=0; i<app_configs.size(); i++) {
908-
APP_CONFIG& ac = app_configs[i];
907+
for (const APP_CONFIG& ac: app_configs) {
909908
out.printf(
910909
" <app>\n"
911910
" <name>%s</name>\n"
@@ -925,8 +924,7 @@ void APP_CONFIGS::write(MIOFILE& out) {
925924
ac.report_results_immediately?1:0
926925
);
927926
}
928-
for (unsigned int i=0; i<app_version_configs.size(); i++) {
929-
APP_VERSION_CONFIG& avc = app_version_configs[i];
927+
for (const APP_VERSION_CONFIG& avc: app_version_configs) {
930928
out.printf(
931929
" <app_version>\n"
932930
" <app_name>%s</app_name>\n"

lib/cc_config.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// This file is part of BOINC.
22
// https://boinc.berkeley.edu
3-
// Copyright (C) 2024 University of California
3+
// Copyright (C) 2026 University of California
44
//
55
// BOINC is free software; you can redistribute it and/or modify it
66
// under the terms of the GNU Lesser General Public License
@@ -143,7 +143,7 @@ struct EXCLUDE_GPU {
143143
int device_num; // -1 means all instances
144144

145145
int parse(XML_PARSER&);
146-
void write(MIOFILE&);
146+
void write(MIOFILE&) const;
147147
};
148148

149149
// if you add anything here, add it to

lib/gui_rpc_client.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// This file is part of BOINC.
22
// https://boinc.berkeley.edu
3-
// Copyright (C) 2023 University of California
3+
// Copyright (C) 2026 University of California
44
//
55
// BOINC is free software; you can redistribute it and/or modify it
66
// under the terms of the GNU Lesser General Public License
@@ -56,7 +56,7 @@ struct GUI_URL {
5656
std::string url;
5757

5858
int parse(XML_PARSER&);
59-
void print();
59+
void print() const;
6060
};
6161

6262
// statistics at a specific day

0 commit comments

Comments
 (0)