diff --git a/test/cpp/qps/limit_cores.cc b/test/cpp/qps/limit_cores.cc
index c9931d9130424b91492b40363adc85e35ef9269a..59ed369067f64231e4919299b14a21a627aef354 100644
--- a/test/cpp/qps/limit_cores.cc
+++ b/test/cpp/qps/limit_cores.cc
@@ -72,13 +72,16 @@ int LimitCores(const int* cores, int cores_size) {
   CPU_FREE(cpup);
   return cores_set;
 }
-#else
 
+}  // namespace testing
+}  // namespace grpc
+#else
 namespace grpc {
 namespace testing {
 
 // LimitCores is not currently supported for non-Linux platforms
 int LimitCores(const int*, int) { return gpr_cpu_num_cores(); }
-#endif
+
 }  // namespace testing
 }  // namespace grpc
+#endif