From: kernel test robot <lkp@intel.com>
To: oe-kbuild@lists.linux.dev
Cc: lkp@intel.com
Subject: proc-empty-vm.c:342:17: warning: ignoring return value of 'write' declared with attribute 'warn_unused_result'
Date: Mon, 1 Apr 2024 02:28:22 +0800 [thread overview]
Message-ID: <202404010211.ygidvMwa-lkp@intel.com> (raw)
::::::
:::::: Manual check reason: "low confidence bisect report"
::::::
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: Swarup Laxman Kotiaklapudi <swarupkotikalapudi@gmail.com>
CC: Andrew Morton <akpm@linux-foundation.org>
CC: Linux Memory Management List <linux-mm@kvack.org>
CC: Alexey Dobriyan <adobriyan@gmail.com>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 712e14250dd2907346617eba275c46f53db8fae7
commit: 6e79b375adb38219099d7e3ccc973a7808108a3e proc: test /proc/${pid}/statm
date: 6 months ago
:::::: branch date: 21 hours ago
:::::: commit date: 6 months ago
compiler: gcc-12 (Ubuntu 12.3.0-9ubuntu2) 12.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240401/202404010211.ygidvMwa-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/r/202404010211.ygidvMwa-lkp@intel.com/
All warnings (new ones prefixed by >>):
proc-empty-vm.c: In function 'test_proc_pid_statm':
>> proc-empty-vm.c:342:17: warning: ignoring return value of 'write' declared with attribute 'warn_unused_result' [-Wunused-result]
342 | write(1, buf, rv);
| ^~~~~~~~~~~~~~~~~
vim +342 tools/testing/selftests/proc/proc-empty-vm.c
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 320
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 321 /*
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 322 * There seems to be 2 types of valid output:
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 323 * "0 A A B 0 0 0\n" for dynamic exeuctables,
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 324 * "0 0 0 B 0 0 0\n" for static executables.
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 325 */
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 326 static int test_proc_pid_statm(pid_t pid)
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 327 {
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 328 char buf[4096];
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 329 snprintf(buf, sizeof(buf), "/proc/%u/statm", pid);
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 330 int fd = open(buf, O_RDONLY);
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 331 if (fd == -1) {
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 332 perror("open /proc/${pid}/statm");
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 333 return EXIT_FAILURE;
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 334 }
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 335
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 336 ssize_t rv = read(fd, buf, sizeof(buf));
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 337 close(fd);
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 338
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 339 assert(rv >= 0);
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 340 assert(rv <= sizeof(buf));
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 341 if (0) {
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 @342 write(1, buf, rv);
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 343 }
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 344
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 345 const char *p = buf;
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 346 const char *const end = p + rv;
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 347
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 348 /* size */
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 349 assert(p != end && *p++ == '0');
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 350 assert(p != end && *p++ == ' ');
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 351
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 352 uint64_t resident;
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 353 p = parse_u64(p, end, &resident);
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 354 assert(p != end && *p++ == ' ');
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 355
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 356 uint64_t shared;
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 357 p = parse_u64(p, end, &shared);
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 358 assert(p != end && *p++ == ' ');
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 359
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 360 uint64_t text;
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 361 p = parse_u64(p, end, &text);
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 362 assert(p != end && *p++ == ' ');
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 363
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 364 assert(p != end && *p++ == '0');
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 365 assert(p != end && *p++ == ' ');
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 366
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 367 /* data */
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 368 assert(p != end && *p++ == '0');
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 369 assert(p != end && *p++ == ' ');
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 370
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 371 assert(p != end && *p++ == '0');
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 372 assert(p != end && *p++ == '\n');
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 373
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 374 assert(p == end);
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 375
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 376 /*
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 377 * "text" is "mm->end_code - mm->start_code" at execve(2) time.
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 378 * munmap() doesn't change it. It can be anything (just link
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 379 * statically). It can't be 0 because executing to this point
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 380 * implies at least 1 page of code.
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 381 */
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 382 assert(text > 0);
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 383
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 384 /*
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 385 * These two are always equal. Always 0 for statically linked
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 386 * executables and sometimes 0 for dynamically linked executables.
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 387 * There is no way to tell one from another without parsing ELF
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 388 * which is too much for this test.
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 389 */
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 390 assert(resident == shared);
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 391
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 392 return EXIT_SUCCESS;
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 393 }
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 394
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
WARNING: multiple messages have this Message-ID (diff)
From: kernel test robot <yujie.liu@intel.com>
To: Swarup Laxman Kotiaklapudi <swarupkotikalapudi@gmail.com>
Cc: <oe-kbuild-all@lists.linux.dev>, <linux-kernel@vger.kernel.org>,
"Andrew Morton" <akpm@linux-foundation.org>,
Linux Memory Management List <linux-mm@kvack.org>,
Alexey Dobriyan <adobriyan@gmail.com>
Subject: proc-empty-vm.c:342:17: warning: ignoring return value of 'write' declared with attribute 'warn_unused_result'
Date: Mon, 1 Apr 2024 10:26:27 +0800 [thread overview]
Message-ID: <202404010211.ygidvMwa-lkp@intel.com> (raw)
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 712e14250dd2907346617eba275c46f53db8fae7
commit: 6e79b375adb38219099d7e3ccc973a7808108a3e proc: test /proc/${pid}/statm
compiler: gcc-12 (Ubuntu 12.3.0-9ubuntu2) 12.3.0
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <yujie.liu@intel.com>
| Closes: https://lore.kernel.org/r/202404010211.ygidvMwa-lkp@intel.com/
All warnings (new ones prefixed by >>):
proc-empty-vm.c: In function 'test_proc_pid_statm':
>> proc-empty-vm.c:342:17: warning: ignoring return value of 'write' declared with attribute 'warn_unused_result' [-Wunused-result]
342 | write(1, buf, rv);
| ^~~~~~~~~~~~~~~~~
vim +342 tools/testing/selftests/proc/proc-empty-vm.c
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 320
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 321 /*
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 322 * There seems to be 2 types of valid output:
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 323 * "0 A A B 0 0 0\n" for dynamic exeuctables,
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 324 * "0 0 0 B 0 0 0\n" for static executables.
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 325 */
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 326 static int test_proc_pid_statm(pid_t pid)
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 327 {
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 328 char buf[4096];
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 329 snprintf(buf, sizeof(buf), "/proc/%u/statm", pid);
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 330 int fd = open(buf, O_RDONLY);
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 331 if (fd == -1) {
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 332 perror("open /proc/${pid}/statm");
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 333 return EXIT_FAILURE;
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 334 }
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 335
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 336 ssize_t rv = read(fd, buf, sizeof(buf));
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 337 close(fd);
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 338
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 339 assert(rv >= 0);
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 340 assert(rv <= sizeof(buf));
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 341 if (0) {
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 @342 write(1, buf, rv);
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 343 }
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 344
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 345 const char *p = buf;
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 346 const char *const end = p + rv;
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 347
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 348 /* size */
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 349 assert(p != end && *p++ == '0');
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 350 assert(p != end && *p++ == ' ');
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 351
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 352 uint64_t resident;
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 353 p = parse_u64(p, end, &resident);
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 354 assert(p != end && *p++ == ' ');
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 355
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 356 uint64_t shared;
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 357 p = parse_u64(p, end, &shared);
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 358 assert(p != end && *p++ == ' ');
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 359
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 360 uint64_t text;
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 361 p = parse_u64(p, end, &text);
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 362 assert(p != end && *p++ == ' ');
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 363
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 364 assert(p != end && *p++ == '0');
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 365 assert(p != end && *p++ == ' ');
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 366
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 367 /* data */
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 368 assert(p != end && *p++ == '0');
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 369 assert(p != end && *p++ == ' ');
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 370
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 371 assert(p != end && *p++ == '0');
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 372 assert(p != end && *p++ == '\n');
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 373
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 374 assert(p == end);
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 375
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 376 /*
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 377 * "text" is "mm->end_code - mm->start_code" at execve(2) time.
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 378 * munmap() doesn't change it. It can be anything (just link
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 379 * statically). It can't be 0 because executing to this point
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 380 * implies at least 1 page of code.
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 381 */
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 382 assert(text > 0);
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 383
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 384 /*
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 385 * These two are always equal. Always 0 for statically linked
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 386 * executables and sometimes 0 for dynamically linked executables.
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 387 * There is no way to tell one from another without parsing ELF
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 388 * which is too much for this test.
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 389 */
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 390 assert(resident == shared);
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 391
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 392 return EXIT_SUCCESS;
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 393 }
6e79b375adb382 Swarup Laxman Kotiaklapudi 2023-10-09 394
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
next reply other threads:[~2024-03-31 18:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-31 18:28 kernel test robot [this message]
2024-04-01 2:26 ` proc-empty-vm.c:342:17: warning: ignoring return value of 'write' declared with attribute 'warn_unused_result' kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202404010211.ygidvMwa-lkp@intel.com \
--to=lkp@intel.com \
--cc=oe-kbuild@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.