* mm/madvise.c:1438:6: warning: Redundant assignment of 'ret' to itself. [selfAssignment]
@ 2023-01-08 3:55 kernel test robot
0 siblings, 0 replies; 10+ messages in thread
From: kernel test robot @ 2023-01-08 3:55 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp
::::::
:::::: Manual check reason: "low confidence static check warning: mm/madvise.c:1438:6: warning: Redundant assignment of 'ret' to itself. [selfAssignment]"
::::::
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: Charan Teja Kalla <quic_charante@quicinc.com>
CC: Andrew Morton <akpm@linux-foundation.org>
CC: Linux Memory Management List <linux-mm@kvack.org>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 9b43a525db125799df81e6fbef712a2ae50bfc5d
commit: 5bd009c7c9a9e888077c07535dc0c70aeab242c3 mm: madvise: return correct bytes advised with process_madvise
date: 10 months ago
:::::: branch date: 9 hours ago
:::::: commit date: 10 months ago
compiler: nios2-linux-gcc (GCC) 12.1.0
reproduce (cppcheck warning):
# apt-get install cppcheck
git checkout 5bd009c7c9a9e888077c07535dc0c70aeab242c3
cppcheck --quiet --enable=style,performance,portability --template=gcc FILE
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
cppcheck possible warnings: (new ones prefixed by >>, may not real problems)
>> mm/madvise.c:1438:6: warning: Redundant assignment of 'ret' to itself. [selfAssignment]
ret = (total_len - iov_iter_count(&iter)) ? : ret;
^
mm/madvise.c:123:28: warning: Parameter 'anon_name' can be declared as pointer to const [constParameter]
struct anon_vma_name *anon_name)
^
vim +/ret +1438 mm/madvise.c
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1378
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1379 SYSCALL_DEFINE5(process_madvise, int, pidfd, const struct iovec __user *, vec,
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1380 size_t, vlen, int, behavior, unsigned int, flags)
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1381 {
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1382 ssize_t ret;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1383 struct iovec iovstack[UIO_FASTIOV], iovec;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1384 struct iovec *iov = iovstack;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1385 struct iov_iter iter;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1386 struct task_struct *task;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1387 struct mm_struct *mm;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1388 size_t total_len;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1389 unsigned int f_flags;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1390
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1391 if (flags != 0) {
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1392 ret = -EINVAL;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1393 goto out;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1394 }
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1395
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1396 ret = import_iovec(READ, vec, vlen, ARRAY_SIZE(iovstack), &iov, &iter);
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1397 if (ret < 0)
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1398 goto out;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1399
ee9955d61a0a77 Christian Brauner 2021-10-11 1400 task = pidfd_get_task(pidfd, &f_flags);
ee9955d61a0a77 Christian Brauner 2021-10-11 1401 if (IS_ERR(task)) {
ee9955d61a0a77 Christian Brauner 2021-10-11 1402 ret = PTR_ERR(task);
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1403 goto free_iov;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1404 }
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1405
a68a0262abdaa2 Minchan Kim 2020-12-08 1406 if (!process_madvise_behavior_valid(behavior)) {
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1407 ret = -EINVAL;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1408 goto release_task;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1409 }
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1410
96cfe2c0fd23ea Suren Baghdasaryan 2021-03-12 1411 /* Require PTRACE_MODE_READ to avoid leaking ASLR metadata. */
96cfe2c0fd23ea Suren Baghdasaryan 2021-03-12 1412 mm = mm_access(task, PTRACE_MODE_READ_FSCREDS);
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1413 if (IS_ERR_OR_NULL(mm)) {
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1414 ret = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1415 goto release_task;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1416 }
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1417
96cfe2c0fd23ea Suren Baghdasaryan 2021-03-12 1418 /*
96cfe2c0fd23ea Suren Baghdasaryan 2021-03-12 1419 * Require CAP_SYS_NICE for influencing process performance. Note that
96cfe2c0fd23ea Suren Baghdasaryan 2021-03-12 1420 * only non-destructive hints are currently supported.
96cfe2c0fd23ea Suren Baghdasaryan 2021-03-12 1421 */
96cfe2c0fd23ea Suren Baghdasaryan 2021-03-12 1422 if (!capable(CAP_SYS_NICE)) {
96cfe2c0fd23ea Suren Baghdasaryan 2021-03-12 1423 ret = -EPERM;
96cfe2c0fd23ea Suren Baghdasaryan 2021-03-12 1424 goto release_mm;
96cfe2c0fd23ea Suren Baghdasaryan 2021-03-12 1425 }
96cfe2c0fd23ea Suren Baghdasaryan 2021-03-12 1426
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1427 total_len = iov_iter_count(&iter);
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1428
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1429 while (iov_iter_count(&iter)) {
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1430 iovec = iov_iter_iovec(&iter);
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1431 ret = do_madvise(mm, (unsigned long)iovec.iov_base,
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1432 iovec.iov_len, behavior);
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1433 if (ret < 0)
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1434 break;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1435 iov_iter_advance(&iter, iovec.iov_len);
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1436 }
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1437
5bd009c7c9a9e8 Charan Teja Kalla 2022-03-22 @1438 ret = (total_len - iov_iter_count(&iter)) ? : ret;
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
^ permalink raw reply [flat|nested] 10+ messages in thread
* mm/madvise.c:1438:6: warning: Redundant assignment of 'ret' to itself. [selfAssignment]
@ 2022-11-21 17:37 kernel test robot
0 siblings, 0 replies; 10+ messages in thread
From: kernel test robot @ 2022-11-21 17:37 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp
::::::
:::::: Manual check reason: "low confidence static check warning: mm/madvise.c:1438:6: warning: Redundant assignment of 'ret' to itself. [selfAssignment]"
::::::
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: Charan Teja Kalla <quic_charante@quicinc.com>
CC: Andrew Morton <akpm@linux-foundation.org>
CC: Linux Memory Management List <linux-mm@kvack.org>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: eb7081409f94a9a8608593d0fb63a1aa3d6f95d8
commit: 5bd009c7c9a9e888077c07535dc0c70aeab242c3 mm: madvise: return correct bytes advised with process_madvise
date: 8 months ago
:::::: branch date: 17 hours ago
:::::: commit date: 8 months ago
compiler: hppa-linux-gcc (GCC) 12.1.0
reproduce (cppcheck warning):
# apt-get install cppcheck
git checkout 5bd009c7c9a9e888077c07535dc0c70aeab242c3
cppcheck --quiet --enable=style,performance,portability --template=gcc FILE
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
cppcheck possible warnings: (new ones prefixed by >>, may not real problems)
>> mm/madvise.c:1438:6: warning: Redundant assignment of 'ret' to itself. [selfAssignment]
ret = (total_len - iov_iter_count(&iter)) ? : ret;
^
mm/madvise.c:123:28: warning: Parameter 'anon_name' can be declared as pointer to const [constParameter]
struct anon_vma_name *anon_name)
^
vim +/ret +1438 mm/madvise.c
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1378
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1379 SYSCALL_DEFINE5(process_madvise, int, pidfd, const struct iovec __user *, vec,
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1380 size_t, vlen, int, behavior, unsigned int, flags)
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1381 {
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1382 ssize_t ret;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1383 struct iovec iovstack[UIO_FASTIOV], iovec;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1384 struct iovec *iov = iovstack;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1385 struct iov_iter iter;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1386 struct task_struct *task;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1387 struct mm_struct *mm;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1388 size_t total_len;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1389 unsigned int f_flags;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1390
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1391 if (flags != 0) {
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1392 ret = -EINVAL;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1393 goto out;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1394 }
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1395
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1396 ret = import_iovec(READ, vec, vlen, ARRAY_SIZE(iovstack), &iov, &iter);
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1397 if (ret < 0)
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1398 goto out;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1399
ee9955d61a0a77 Christian Brauner 2021-10-11 1400 task = pidfd_get_task(pidfd, &f_flags);
ee9955d61a0a77 Christian Brauner 2021-10-11 1401 if (IS_ERR(task)) {
ee9955d61a0a77 Christian Brauner 2021-10-11 1402 ret = PTR_ERR(task);
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1403 goto free_iov;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1404 }
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1405
a68a0262abdaa2 Minchan Kim 2020-12-08 1406 if (!process_madvise_behavior_valid(behavior)) {
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1407 ret = -EINVAL;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1408 goto release_task;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1409 }
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1410
96cfe2c0fd23ea Suren Baghdasaryan 2021-03-12 1411 /* Require PTRACE_MODE_READ to avoid leaking ASLR metadata. */
96cfe2c0fd23ea Suren Baghdasaryan 2021-03-12 1412 mm = mm_access(task, PTRACE_MODE_READ_FSCREDS);
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1413 if (IS_ERR_OR_NULL(mm)) {
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1414 ret = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1415 goto release_task;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1416 }
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1417
96cfe2c0fd23ea Suren Baghdasaryan 2021-03-12 1418 /*
96cfe2c0fd23ea Suren Baghdasaryan 2021-03-12 1419 * Require CAP_SYS_NICE for influencing process performance. Note that
96cfe2c0fd23ea Suren Baghdasaryan 2021-03-12 1420 * only non-destructive hints are currently supported.
96cfe2c0fd23ea Suren Baghdasaryan 2021-03-12 1421 */
96cfe2c0fd23ea Suren Baghdasaryan 2021-03-12 1422 if (!capable(CAP_SYS_NICE)) {
96cfe2c0fd23ea Suren Baghdasaryan 2021-03-12 1423 ret = -EPERM;
96cfe2c0fd23ea Suren Baghdasaryan 2021-03-12 1424 goto release_mm;
96cfe2c0fd23ea Suren Baghdasaryan 2021-03-12 1425 }
96cfe2c0fd23ea Suren Baghdasaryan 2021-03-12 1426
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1427 total_len = iov_iter_count(&iter);
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1428
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1429 while (iov_iter_count(&iter)) {
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1430 iovec = iov_iter_iovec(&iter);
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1431 ret = do_madvise(mm, (unsigned long)iovec.iov_base,
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1432 iovec.iov_len, behavior);
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1433 if (ret < 0)
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1434 break;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1435 iov_iter_advance(&iter, iovec.iov_len);
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1436 }
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1437
5bd009c7c9a9e8 Charan Teja Kalla 2022-03-22 @1438 ret = (total_len - iov_iter_count(&iter)) ? : ret;
--
0-DAY CI Kernel Test Service
https://01.org/lkp
^ permalink raw reply [flat|nested] 10+ messages in thread
* mm/madvise.c:1438:6: warning: Redundant assignment of 'ret' to itself. [selfAssignment]
@ 2022-07-11 15:23 kernel test robot
0 siblings, 0 replies; 10+ messages in thread
From: kernel test robot @ 2022-07-11 15:23 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 6281 bytes --]
::::::
:::::: Manual check reason: "low confidence static check warning: mm/madvise.c:1438:6: warning: Redundant assignment of 'ret' to itself. [selfAssignment]"
::::::
CC: kbuild-all(a)lists.01.org
BCC: lkp(a)intel.com
CC: linux-kernel(a)vger.kernel.org
TO: Charan Teja Kalla <quic_charante@quicinc.com>
CC: Andrew Morton <akpm@linux-foundation.org>
CC: Linux Memory Management List <linux-mm@kvack.org>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 32346491ddf24599decca06190ebca03ff9de7f8
commit: 5bd009c7c9a9e888077c07535dc0c70aeab242c3 mm: madvise: return correct bytes advised with process_madvise
date: 4 months ago
:::::: branch date: 18 hours ago
:::::: commit date: 4 months ago
compiler: nios2-linux-gcc (GCC) 11.3.0
reproduce (cppcheck warning):
# apt-get install cppcheck
git checkout 5bd009c7c9a9e888077c07535dc0c70aeab242c3
cppcheck --quiet --enable=style,performance,portability --template=gcc FILE
If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>
cppcheck possible warnings: (new ones prefixed by >>, may not real problems)
>> mm/madvise.c:1438:6: warning: Redundant assignment of 'ret' to itself. [selfAssignment]
ret = (total_len - iov_iter_count(&iter)) ? : ret;
^
mm/madvise.c:123:28: warning: Parameter 'anon_name' can be declared with const [constParameter]
struct anon_vma_name *anon_name)
^
vim +/ret +1438 mm/madvise.c
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1378
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1379 SYSCALL_DEFINE5(process_madvise, int, pidfd, const struct iovec __user *, vec,
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1380 size_t, vlen, int, behavior, unsigned int, flags)
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1381 {
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1382 ssize_t ret;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1383 struct iovec iovstack[UIO_FASTIOV], iovec;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1384 struct iovec *iov = iovstack;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1385 struct iov_iter iter;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1386 struct task_struct *task;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1387 struct mm_struct *mm;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1388 size_t total_len;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1389 unsigned int f_flags;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1390
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1391 if (flags != 0) {
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1392 ret = -EINVAL;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1393 goto out;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1394 }
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1395
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1396 ret = import_iovec(READ, vec, vlen, ARRAY_SIZE(iovstack), &iov, &iter);
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1397 if (ret < 0)
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1398 goto out;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1399
ee9955d61a0a77 Christian Brauner 2021-10-11 1400 task = pidfd_get_task(pidfd, &f_flags);
ee9955d61a0a77 Christian Brauner 2021-10-11 1401 if (IS_ERR(task)) {
ee9955d61a0a77 Christian Brauner 2021-10-11 1402 ret = PTR_ERR(task);
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1403 goto free_iov;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1404 }
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1405
a68a0262abdaa2 Minchan Kim 2020-12-08 1406 if (!process_madvise_behavior_valid(behavior)) {
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1407 ret = -EINVAL;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1408 goto release_task;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1409 }
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1410
96cfe2c0fd23ea Suren Baghdasaryan 2021-03-12 1411 /* Require PTRACE_MODE_READ to avoid leaking ASLR metadata. */
96cfe2c0fd23ea Suren Baghdasaryan 2021-03-12 1412 mm = mm_access(task, PTRACE_MODE_READ_FSCREDS);
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1413 if (IS_ERR_OR_NULL(mm)) {
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1414 ret = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1415 goto release_task;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1416 }
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1417
96cfe2c0fd23ea Suren Baghdasaryan 2021-03-12 1418 /*
96cfe2c0fd23ea Suren Baghdasaryan 2021-03-12 1419 * Require CAP_SYS_NICE for influencing process performance. Note that
96cfe2c0fd23ea Suren Baghdasaryan 2021-03-12 1420 * only non-destructive hints are currently supported.
96cfe2c0fd23ea Suren Baghdasaryan 2021-03-12 1421 */
96cfe2c0fd23ea Suren Baghdasaryan 2021-03-12 1422 if (!capable(CAP_SYS_NICE)) {
96cfe2c0fd23ea Suren Baghdasaryan 2021-03-12 1423 ret = -EPERM;
96cfe2c0fd23ea Suren Baghdasaryan 2021-03-12 1424 goto release_mm;
96cfe2c0fd23ea Suren Baghdasaryan 2021-03-12 1425 }
96cfe2c0fd23ea Suren Baghdasaryan 2021-03-12 1426
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1427 total_len = iov_iter_count(&iter);
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1428
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1429 while (iov_iter_count(&iter)) {
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1430 iovec = iov_iter_iovec(&iter);
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1431 ret = do_madvise(mm, (unsigned long)iovec.iov_base,
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1432 iovec.iov_len, behavior);
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1433 if (ret < 0)
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1434 break;
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1435 iov_iter_advance(&iter, iovec.iov_len);
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1436 }
ecb8ac8b1f1469 Minchan Kim 2020-10-17 1437
5bd009c7c9a9e8 Charan Teja Kalla 2022-03-22 @1438 ret = (total_len - iov_iter_count(&iter)) ? : ret;
--
0-DAY CI Kernel Test Service
https://01.org/lkp
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: mm/madvise.c:1438:6: warning: Redundant assignment of 'ret' to itself. [selfAssignment]
2022-06-20 16:54 ` Julia Lawall
@ 2022-06-20 19:14 ` Michal Hocko
0 siblings, 0 replies; 10+ messages in thread
From: Michal Hocko @ 2022-06-20 19:14 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 1927 bytes --]
On Mon 20-06-22 12:54:56, Julia Lawall wrote:
>
>
> On Mon, 20 Jun 2022, Michal Hocko wrote:
>
> > On Sat 18-06-22 11:25:43, Charan Teja Kalla wrote:
> > > Hello Andrew,
> > >
> > > On 6/18/2022 4:34 AM, kernel test robot wrote:
> > > > tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> > > > head: 4b35035bcf80ddb47c0112c4fbd84a63a2836a18
> > > > commit: 5bd009c7c9a9e888077c07535dc0c70aeab242c3 mm: madvise: return correct bytes advised with process_madvise
> > > > date: 3 months ago
> > > > compiler: mips-linux-gcc (GCC) 11.3.0
> > > > reproduce (cppcheck warning):
> > > > # apt-get install cppcheck
> > > > git checkout 5bd009c7c9a9e888077c07535dc0c70aeab242c3
> > > > cppcheck --quiet --enable=style,performance,portability --template=gcc FILE
> > > >
> > > > If you fix the issue, kindly add following tag where applicable
> > > > Reported-by: kernel test robot <lkp@intel.com>
> > > >
> > > >
> > > > cppcheck warnings: (new ones prefixed by >>)
> > > >>> mm/madvise.c:1438:6: warning: Redundant assignment of 'ret' to itself. [selfAssignment]
> > > > ret = (total_len - iov_iter_count(&iter)) ? : ret;
> > >
> > > Other way to avoid this warning is by creating another local variable
> > > that holds the total bytes processed. Having another local variable to
> > > get rid off some compilation warning doesn't seem proper to me. So,
> > > leaving this warning unless you ask me to fix this.
> >
> > Is this a new warning? I do not see it supported by my gcc 10.x. Do we
>
> cppcheck is a static analysis tool. It looks like it doesn't have a
> proper understanding of ?:
Ohh, thanks for the clarification! I thought this was a gcc feature.
Then I would suggest to report a bug report against the static checker
rather than making any changes to the kernel to workaround it.
--
Michal Hocko
SUSE Labs
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: mm/madvise.c:1438:6: warning: Redundant assignment of 'ret' to itself. [selfAssignment]
2022-06-20 16:29 ` Michal Hocko
(?)
@ 2022-06-20 16:54 ` Julia Lawall
2022-06-20 19:14 ` Michal Hocko
-1 siblings, 1 reply; 10+ messages in thread
From: Julia Lawall @ 2022-06-20 16:54 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 2174 bytes --]
On Mon, 20 Jun 2022, Michal Hocko wrote:
> On Sat 18-06-22 11:25:43, Charan Teja Kalla wrote:
> > Hello Andrew,
> >
> > On 6/18/2022 4:34 AM, kernel test robot wrote:
> > > tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> > > head: 4b35035bcf80ddb47c0112c4fbd84a63a2836a18
> > > commit: 5bd009c7c9a9e888077c07535dc0c70aeab242c3 mm: madvise: return correct bytes advised with process_madvise
> > > date: 3 months ago
> > > compiler: mips-linux-gcc (GCC) 11.3.0
> > > reproduce (cppcheck warning):
> > > # apt-get install cppcheck
> > > git checkout 5bd009c7c9a9e888077c07535dc0c70aeab242c3
> > > cppcheck --quiet --enable=style,performance,portability --template=gcc FILE
> > >
> > > If you fix the issue, kindly add following tag where applicable
> > > Reported-by: kernel test robot <lkp@intel.com>
> > >
> > >
> > > cppcheck warnings: (new ones prefixed by >>)
> > >>> mm/madvise.c:1438:6: warning: Redundant assignment of 'ret' to itself. [selfAssignment]
> > > ret = (total_len - iov_iter_count(&iter)) ? : ret;
> >
> > Other way to avoid this warning is by creating another local variable
> > that holds the total bytes processed. Having another local variable to
> > get rid off some compilation warning doesn't seem proper to me. So,
> > leaving this warning unless you ask me to fix this.
>
> Is this a new warning? I do not see it supported by my gcc 10.x. Do we
cppcheck is a static analysis tool. It looks like it doesn't have a
proper understanding of ?:
julia
> plan to have it enabled by default? I do not see anything wrong with the
> above code and I think this is not an unusual pattern in the kernel.
> While you could go with
> if (rotal_len - iov_iter_count(&iter))
> ret = rotal_len - iov_iter_count(&iter);
>
> or do the same with a temporary variable but I am not really sure this would
> add to the readability much.
> --
> Michal Hocko
> SUSE Labs
> _______________________________________________
> kbuild-all mailing list -- kbuild-all(a)lists.01.org
> To unsubscribe send an email to kbuild-all-leave(a)lists.01.org
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: mm/madvise.c:1438:6: warning: Redundant assignment of 'ret' to itself. [selfAssignment]
2022-06-18 5:55 ` Charan Teja Kalla
@ 2022-06-20 16:29 ` Michal Hocko
-1 siblings, 0 replies; 10+ messages in thread
From: Michal Hocko @ 2022-06-20 16:29 UTC (permalink / raw)
To: Charan Teja Kalla
Cc: kernel test robot, Minchan Kim, kbuild-all, linux-kernel,
Andrew Morton, Linux Memory Management List
On Sat 18-06-22 11:25:43, Charan Teja Kalla wrote:
> Hello Andrew,
>
> On 6/18/2022 4:34 AM, kernel test robot wrote:
> > tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> > head: 4b35035bcf80ddb47c0112c4fbd84a63a2836a18
> > commit: 5bd009c7c9a9e888077c07535dc0c70aeab242c3 mm: madvise: return correct bytes advised with process_madvise
> > date: 3 months ago
> > compiler: mips-linux-gcc (GCC) 11.3.0
> > reproduce (cppcheck warning):
> > # apt-get install cppcheck
> > git checkout 5bd009c7c9a9e888077c07535dc0c70aeab242c3
> > cppcheck --quiet --enable=style,performance,portability --template=gcc FILE
> >
> > If you fix the issue, kindly add following tag where applicable
> > Reported-by: kernel test robot <lkp@intel.com>
> >
> >
> > cppcheck warnings: (new ones prefixed by >>)
> >>> mm/madvise.c:1438:6: warning: Redundant assignment of 'ret' to itself. [selfAssignment]
> > ret = (total_len - iov_iter_count(&iter)) ? : ret;
>
> Other way to avoid this warning is by creating another local variable
> that holds the total bytes processed. Having another local variable to
> get rid off some compilation warning doesn't seem proper to me. So,
> leaving this warning unless you ask me to fix this.
Is this a new warning? I do not see it supported by my gcc 10.x. Do we
plan to have it enabled by default? I do not see anything wrong with the
above code and I think this is not an unusual pattern in the kernel.
While you could go with
if (rotal_len - iov_iter_count(&iter))
ret = rotal_len - iov_iter_count(&iter);
or do the same with a temporary variable but I am not really sure this would
add to the readability much.
--
Michal Hocko
SUSE Labs
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: mm/madvise.c:1438:6: warning: Redundant assignment of 'ret' to itself. [selfAssignment]
@ 2022-06-20 16:29 ` Michal Hocko
0 siblings, 0 replies; 10+ messages in thread
From: Michal Hocko @ 2022-06-20 16:29 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 1768 bytes --]
On Sat 18-06-22 11:25:43, Charan Teja Kalla wrote:
> Hello Andrew,
>
> On 6/18/2022 4:34 AM, kernel test robot wrote:
> > tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> > head: 4b35035bcf80ddb47c0112c4fbd84a63a2836a18
> > commit: 5bd009c7c9a9e888077c07535dc0c70aeab242c3 mm: madvise: return correct bytes advised with process_madvise
> > date: 3 months ago
> > compiler: mips-linux-gcc (GCC) 11.3.0
> > reproduce (cppcheck warning):
> > # apt-get install cppcheck
> > git checkout 5bd009c7c9a9e888077c07535dc0c70aeab242c3
> > cppcheck --quiet --enable=style,performance,portability --template=gcc FILE
> >
> > If you fix the issue, kindly add following tag where applicable
> > Reported-by: kernel test robot <lkp@intel.com>
> >
> >
> > cppcheck warnings: (new ones prefixed by >>)
> >>> mm/madvise.c:1438:6: warning: Redundant assignment of 'ret' to itself. [selfAssignment]
> > ret = (total_len - iov_iter_count(&iter)) ? : ret;
>
> Other way to avoid this warning is by creating another local variable
> that holds the total bytes processed. Having another local variable to
> get rid off some compilation warning doesn't seem proper to me. So,
> leaving this warning unless you ask me to fix this.
Is this a new warning? I do not see it supported by my gcc 10.x. Do we
plan to have it enabled by default? I do not see anything wrong with the
above code and I think this is not an unusual pattern in the kernel.
While you could go with
if (rotal_len - iov_iter_count(&iter))
ret = rotal_len - iov_iter_count(&iter);
or do the same with a temporary variable but I am not really sure this would
add to the readability much.
--
Michal Hocko
SUSE Labs
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: mm/madvise.c:1438:6: warning: Redundant assignment of 'ret' to itself. [selfAssignment]
2022-06-17 23:04 kernel test robot
@ 2022-06-18 5:55 ` Charan Teja Kalla
0 siblings, 0 replies; 10+ messages in thread
From: Charan Teja Kalla @ 2022-06-18 5:55 UTC (permalink / raw)
To: kernel test robot, Michal Hocko, Minchan Kim
Cc: kbuild-all, linux-kernel, Andrew Morton, Linux Memory Management List
Hello Andrew,
On 6/18/2022 4:34 AM, kernel test robot wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head: 4b35035bcf80ddb47c0112c4fbd84a63a2836a18
> commit: 5bd009c7c9a9e888077c07535dc0c70aeab242c3 mm: madvise: return correct bytes advised with process_madvise
> date: 3 months ago
> compiler: mips-linux-gcc (GCC) 11.3.0
> reproduce (cppcheck warning):
> # apt-get install cppcheck
> git checkout 5bd009c7c9a9e888077c07535dc0c70aeab242c3
> cppcheck --quiet --enable=style,performance,portability --template=gcc FILE
>
> If you fix the issue, kindly add following tag where applicable
> Reported-by: kernel test robot <lkp@intel.com>
>
>
> cppcheck warnings: (new ones prefixed by >>)
>>> mm/madvise.c:1438:6: warning: Redundant assignment of 'ret' to itself. [selfAssignment]
> ret = (total_len - iov_iter_count(&iter)) ? : ret;
Other way to avoid this warning is by creating another local variable
that holds the total bytes processed. Having another local variable to
get rid off some compilation warning doesn't seem proper to me. So,
leaving this warning unless you ask me to fix this.
Thanks,
Charan
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: mm/madvise.c:1438:6: warning: Redundant assignment of 'ret' to itself. [selfAssignment]
@ 2022-06-18 5:55 ` Charan Teja Kalla
0 siblings, 0 replies; 10+ messages in thread
From: Charan Teja Kalla @ 2022-06-18 5:55 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 1217 bytes --]
Hello Andrew,
On 6/18/2022 4:34 AM, kernel test robot wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head: 4b35035bcf80ddb47c0112c4fbd84a63a2836a18
> commit: 5bd009c7c9a9e888077c07535dc0c70aeab242c3 mm: madvise: return correct bytes advised with process_madvise
> date: 3 months ago
> compiler: mips-linux-gcc (GCC) 11.3.0
> reproduce (cppcheck warning):
> # apt-get install cppcheck
> git checkout 5bd009c7c9a9e888077c07535dc0c70aeab242c3
> cppcheck --quiet --enable=style,performance,portability --template=gcc FILE
>
> If you fix the issue, kindly add following tag where applicable
> Reported-by: kernel test robot <lkp@intel.com>
>
>
> cppcheck warnings: (new ones prefixed by >>)
>>> mm/madvise.c:1438:6: warning: Redundant assignment of 'ret' to itself. [selfAssignment]
> ret = (total_len - iov_iter_count(&iter)) ? : ret;
Other way to avoid this warning is by creating another local variable
that holds the total bytes processed. Having another local variable to
get rid off some compilation warning doesn't seem proper to me. So,
leaving this warning unless you ask me to fix this.
Thanks,
Charan
^ permalink raw reply [flat|nested] 10+ messages in thread
* mm/madvise.c:1438:6: warning: Redundant assignment of 'ret' to itself. [selfAssignment]
@ 2022-06-17 23:04 kernel test robot
2022-06-18 5:55 ` Charan Teja Kalla
0 siblings, 1 reply; 10+ messages in thread
From: kernel test robot @ 2022-06-17 23:04 UTC (permalink / raw)
To: Charan Teja Kalla
Cc: kbuild-all, linux-kernel, Andrew Morton, Linux Memory Management List
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 4b35035bcf80ddb47c0112c4fbd84a63a2836a18
commit: 5bd009c7c9a9e888077c07535dc0c70aeab242c3 mm: madvise: return correct bytes advised with process_madvise
date: 3 months ago
compiler: mips-linux-gcc (GCC) 11.3.0
reproduce (cppcheck warning):
# apt-get install cppcheck
git checkout 5bd009c7c9a9e888077c07535dc0c70aeab242c3
cppcheck --quiet --enable=style,performance,portability --template=gcc FILE
If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>
cppcheck warnings: (new ones prefixed by >>)
>> mm/madvise.c:1438:6: warning: Redundant assignment of 'ret' to itself. [selfAssignment]
ret = (total_len - iov_iter_count(&iter)) ? : ret;
^
cppcheck possible warnings: (new ones prefixed by >>, may not real problems)
mm/madvise.c:123:28: warning: Parameter 'anon_name' can be declared with const [constParameter]
struct anon_vma_name *anon_name)
^
vim +/ret +1438 mm/madvise.c
1378
1379 SYSCALL_DEFINE5(process_madvise, int, pidfd, const struct iovec __user *, vec,
1380 size_t, vlen, int, behavior, unsigned int, flags)
1381 {
1382 ssize_t ret;
1383 struct iovec iovstack[UIO_FASTIOV], iovec;
1384 struct iovec *iov = iovstack;
1385 struct iov_iter iter;
1386 struct task_struct *task;
1387 struct mm_struct *mm;
1388 size_t total_len;
1389 unsigned int f_flags;
1390
1391 if (flags != 0) {
1392 ret = -EINVAL;
1393 goto out;
1394 }
1395
1396 ret = import_iovec(READ, vec, vlen, ARRAY_SIZE(iovstack), &iov, &iter);
1397 if (ret < 0)
1398 goto out;
1399
1400 task = pidfd_get_task(pidfd, &f_flags);
1401 if (IS_ERR(task)) {
1402 ret = PTR_ERR(task);
1403 goto free_iov;
1404 }
1405
1406 if (!process_madvise_behavior_valid(behavior)) {
1407 ret = -EINVAL;
1408 goto release_task;
1409 }
1410
1411 /* Require PTRACE_MODE_READ to avoid leaking ASLR metadata. */
1412 mm = mm_access(task, PTRACE_MODE_READ_FSCREDS);
1413 if (IS_ERR_OR_NULL(mm)) {
1414 ret = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
1415 goto release_task;
1416 }
1417
1418 /*
1419 * Require CAP_SYS_NICE for influencing process performance. Note that
1420 * only non-destructive hints are currently supported.
1421 */
1422 if (!capable(CAP_SYS_NICE)) {
1423 ret = -EPERM;
1424 goto release_mm;
1425 }
1426
1427 total_len = iov_iter_count(&iter);
1428
1429 while (iov_iter_count(&iter)) {
1430 iovec = iov_iter_iovec(&iter);
1431 ret = do_madvise(mm, (unsigned long)iovec.iov_base,
1432 iovec.iov_len, behavior);
1433 if (ret < 0)
1434 break;
1435 iov_iter_advance(&iter, iovec.iov_len);
1436 }
1437
> 1438 ret = (total_len - iov_iter_count(&iter)) ? : ret;
--
0-DAY CI Kernel Test Service
https://01.org/lkp
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2023-01-08 3:56 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-08 3:55 mm/madvise.c:1438:6: warning: Redundant assignment of 'ret' to itself. [selfAssignment] kernel test robot
-- strict thread matches above, loose matches on Subject: below --
2022-11-21 17:37 kernel test robot
2022-07-11 15:23 kernel test robot
2022-06-17 23:04 kernel test robot
2022-06-18 5:55 ` Charan Teja Kalla
2022-06-18 5:55 ` Charan Teja Kalla
2022-06-20 16:29 ` Michal Hocko
2022-06-20 16:29 ` Michal Hocko
2022-06-20 16:54 ` Julia Lawall
2022-06-20 19:14 ` Michal Hocko
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.