arch/powerpc/platforms/cell/spufs/coredump.c:124 spufs_arch_write_note() warn: unsigned 'ret' is never less than zero.

From: kernel test robot
Date: Wed Jun 10 2020 - 15:34:39 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 5b14671be58d0084e7e2d1cc9c2c36a94467f6e0
commit: 5456ffdee666c66e27ccc1006f9afe83ad55559f powerpc/spufs: simplify spufs core dumping
date: 5 weeks ago
config: powerpc-randconfig-m031-20200607 (attached as .config)
compiler: powerpc64-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

smatch warnings:
arch/powerpc/platforms/cell/spufs/coredump.c:124 spufs_arch_write_note() warn: unsigned 'ret' is never less than zero.

vim +/ret +124 arch/powerpc/platforms/cell/spufs/coredump.c

101
102 static int spufs_arch_write_note(struct spu_context *ctx, int i,
103 struct coredump_params *cprm, int dfd)
104 {
105 size_t sz = spufs_coredump_read[i].size;
106 char fullname[80];
107 struct elf_note en;
108 size_t ret;
109
110 sprintf(fullname, "SPU/%d/%s", dfd, spufs_coredump_read[i].name);
111 en.n_namesz = strlen(fullname) + 1;
112 en.n_descsz = sz;
113 en.n_type = NT_SPU;
114
115 if (!dump_emit(cprm, &en, sizeof(en)))
116 return -EIO;
117 if (!dump_emit(cprm, fullname, en.n_namesz))
118 return -EIO;
119 if (!dump_align(cprm, 4))
120 return -EIO;
121
122 if (spufs_coredump_read[i].dump) {
123 ret = spufs_coredump_read[i].dump(ctx, cprm);
> 124 if (ret < 0)
125 return ret;
126 } else {
127 char buf[32];
128
129 ret = snprintf(buf, sizeof(buf), "0x%.16llx",
130 spufs_coredump_read[i].get(ctx));
131 if (ret >= sizeof(buf))
132 return sizeof(buf);
133
134 /* count trailing the NULL: */
135 if (!dump_emit(cprm, buf, ret + 1))
136 return -EIO;
137 }
138
139 if (!dump_skip(cprm, roundup(cprm->pos - ret + sz, 4) - cprm->pos))
140 return -EIO;
141 return 0;
142 }
143

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip