Copilot commented on code in PR #13219:
URL: https://github.com/apache/trafficserver/pull/13219#discussion_r3337175639


##########
src/tscore/ink_sys_control.cc:
##########
@@ -98,3 +110,58 @@ ink_get_max_files()
 
   return RLIM_INFINITY;
 }
+
+uint64_t
+ink_get_current_rss()
+{
+#if defined(__linux__)
+  // /proc/self/statm reports sizes in pages. The second field is the resident
+  // set size (number of resident pages).
+  FILE *fp = fopen("/proc/self/statm", "r");
+  if (fp == nullptr) {
+    return 0;
+  }
+
+  unsigned long total_pages    = 0;
+  unsigned long resident_pages = 0;
+  int           matched        = fscanf(fp, "%lu %lu", &total_pages, 
&resident_pages);
+  fclose(fp);
+
+  if (matched != 2) {
+    return 0;
+  }

Review Comment:
   In the Linux /proc/self/statm parsing, `total_pages` is only used as a sink 
for `fscanf` and never read afterward. This can trigger 
`-Wunused-but-set-variable` (often treated as an error in ATS builds). Consider 
skipping the first field with `%*lu` and only storing `resident_pages`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to