From 85f1c7e8a068c98189830d9109f22ac4286d8a12 Mon Sep 17 00:00:00 2001 From: Michael Chirico Date: Sat, 3 Aug 2024 05:04:53 +0000 Subject: [PATCH] simplify, comment --- .ci/linters/c/omp_set_num_threads_linter.R | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.ci/linters/c/omp_set_num_threads_linter.R b/.ci/linters/c/omp_set_num_threads_linter.R index 6a94b2527..a707d1748 100644 --- a/.ci/linters/c/omp_set_num_threads_linter.R +++ b/.ci/linters/c/omp_set_num_threads_linter.R @@ -1,11 +1,13 @@ + # Ensure no calls to omp_set_num_threads() [to avoid affecting other packages and base R] # Only comments referring to it should be in openmp-utils.c omp_set_num_threads_linter = function(c_file) { - processed_lines = system2("gcc", c("-fpreprocessed", "-E", "-xc", "-"), stdin=c_file, stdout=TRUE, stderr=FALSE) + # strip comments, we only care if the function appears in actual code. + processed_lines = system2("gcc", c("-fpreprocessed", "-E", "-xc", "-", c_file), stdout=TRUE, stderr=FALSE) idx = grep("omp_set_num_threads", processed_lines, fixed = TRUE) if (!length(idx)) return() stop(sprintf( - "In %s, found 'omp_set_num_threads() usage, which could affect other packages and base R:\n%s", + "In %s, found omp_set_num_threads() usage, which could affect other packages and base R:\n%s", c_file, paste0(" ", format(idx), ":", processed_lines[idx], collapse = "\n") )) }