From: kernel test robot <lkp@intel.com>
To: oe-kbuild@lists.linux.dev
Cc: lkp@intel.com, Julia Lawall <julia.lawall@inria.fr>
Subject: drivers/scsi/sd.c:2183:7-17: WARNING: Unsigned expression compared with zero: the_result > 0
Date: Thu, 7 Dec 2023 01:05:26 +0800 [thread overview]
Message-ID: <202312070013.1Fps4LEH-lkp@intel.com> (raw)
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: Mike Christie <michael.christie@oracle.com>
CC: "Martin K. Petersen" <martin.petersen@oracle.com>
CC: Christoph Hellwig <hch@lst.de>
CC: John Garry <john.g.garry@oracle.com>
CC: Bart Van Assche <bvanassche@acm.org>
CC: Martin Wilck <mwilck@suse.com>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: bee0e7762ad2c6025b9f5245c040fcc36ef2bde8
commit: b4d0c33a32c3c59217ec449de3892b1a6d68cbc1 scsi: sd: Fix sshdr use in sd_spinup_disk
date: 8 weeks ago
:::::: branch date: 2 days ago
:::::: commit date: 8 weeks ago
config: x86_64-randconfig-102-20231202 (https://download.01.org/0day-ci/archive/20231207/202312070013.1Fps4LEH-lkp@intel.com/config)
compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07)
reproduce: (https://download.01.org/0day-ci/archive/20231207/202312070013.1Fps4LEH-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>
| Reported-by: Julia Lawall <julia.lawall@inria.fr>
| Closes: https://lore.kernel.org/r/202312070013.1Fps4LEH-lkp@intel.com/
cocci warnings: (new ones prefixed by >>)
>> drivers/scsi/sd.c:2183:7-17: WARNING: Unsigned expression compared with zero: the_result > 0
vim +2183 drivers/scsi/sd.c
^1da177e4c3f41 Linus Torvalds 2005-04-16 2147
^1da177e4c3f41 Linus Torvalds 2005-04-16 2148 /*
^1da177e4c3f41 Linus Torvalds 2005-04-16 2149 * spinup disk - called only in sd_revalidate_disk()
^1da177e4c3f41 Linus Torvalds 2005-04-16 2150 */
^1da177e4c3f41 Linus Torvalds 2005-04-16 2151 static void
e73aec8247032e Martin K. Petersen 2007-02-27 2152 sd_spinup_disk(struct scsi_disk *sdkp)
ea73a9f23906c3 James Bottomley 2005-08-28 2153 {
^1da177e4c3f41 Linus Torvalds 2005-04-16 2154 unsigned char cmd[10];
4451e472627881 Alan Stern 2005-07-12 2155 unsigned long spintime_expire = 0;
^1da177e4c3f41 Linus Torvalds 2005-04-16 2156 int retries, spintime;
^1da177e4c3f41 Linus Torvalds 2005-04-16 2157 unsigned int the_result;
^1da177e4c3f41 Linus Torvalds 2005-04-16 2158 struct scsi_sense_hdr sshdr;
af16cd63d9d3b7 Mike Christie 2022-12-29 2159 const struct scsi_exec_args exec_args = {
af16cd63d9d3b7 Mike Christie 2022-12-29 2160 .sshdr = &sshdr,
af16cd63d9d3b7 Mike Christie 2022-12-29 2161 };
^1da177e4c3f41 Linus Torvalds 2005-04-16 2162 int sense_valid = 0;
^1da177e4c3f41 Linus Torvalds 2005-04-16 2163
^1da177e4c3f41 Linus Torvalds 2005-04-16 2164 spintime = 0;
^1da177e4c3f41 Linus Torvalds 2005-04-16 2165
^1da177e4c3f41 Linus Torvalds 2005-04-16 2166 /* Spin up drives, as required. Only do this at boot time */
^1da177e4c3f41 Linus Torvalds 2005-04-16 2167 /* Spinup needs to be done for module loads too. */
^1da177e4c3f41 Linus Torvalds 2005-04-16 2168 do {
^1da177e4c3f41 Linus Torvalds 2005-04-16 2169 retries = 0;
^1da177e4c3f41 Linus Torvalds 2005-04-16 2170
^1da177e4c3f41 Linus Torvalds 2005-04-16 2171 do {
4521428c48118b Heiner Kallweit 2021-09-11 2172 bool media_was_present = sdkp->media_present;
4521428c48118b Heiner Kallweit 2021-09-11 2173
^1da177e4c3f41 Linus Torvalds 2005-04-16 2174 cmd[0] = TEST_UNIT_READY;
^1da177e4c3f41 Linus Torvalds 2005-04-16 2175 memset((void *) &cmd[1], 0, 9);
^1da177e4c3f41 Linus Torvalds 2005-04-16 2176
af16cd63d9d3b7 Mike Christie 2022-12-29 2177 the_result = scsi_execute_cmd(sdkp->device, cmd,
af16cd63d9d3b7 Mike Christie 2022-12-29 2178 REQ_OP_DRV_IN, NULL, 0,
af16cd63d9d3b7 Mike Christie 2022-12-29 2179 SD_TIMEOUT,
af16cd63d9d3b7 Mike Christie 2022-12-29 2180 sdkp->max_retries,
af16cd63d9d3b7 Mike Christie 2022-12-29 2181 &exec_args);
^1da177e4c3f41 Linus Torvalds 2005-04-16 2182
b4d0c33a32c3c5 Mike Christie 2023-10-04 @2183 if (the_result > 0) {
b4d38e38e66f8e Alan Stern 2006-10-11 2184 /*
b4d38e38e66f8e Alan Stern 2006-10-11 2185 * If the drive has indicated to us that it
b4d38e38e66f8e Alan Stern 2006-10-11 2186 * doesn't have any media in it, don't bother
b4d38e38e66f8e Alan Stern 2006-10-11 2187 * with any more polling.
b4d38e38e66f8e Alan Stern 2006-10-11 2188 */
848ade90ba9c1e Christian Loehle 2021-08-16 2189 if (media_not_present(sdkp, &sshdr)) {
4521428c48118b Heiner Kallweit 2021-09-11 2190 if (media_was_present)
b4d0c33a32c3c5 Mike Christie 2023-10-04 2191 sd_printk(KERN_NOTICE, sdkp,
b4d0c33a32c3c5 Mike Christie 2023-10-04 2192 "Media removed, stopped polling\n");
b4d38e38e66f8e Alan Stern 2006-10-11 2193 return;
848ade90ba9c1e Christian Loehle 2021-08-16 2194 }
b4d38e38e66f8e Alan Stern 2006-10-11 2195
ea73a9f23906c3 James Bottomley 2005-08-28 2196 sense_valid = scsi_sense_valid(&sshdr);
b4d0c33a32c3c5 Mike Christie 2023-10-04 2197 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 2198 retries++;
^1da177e4c3f41 Linus Torvalds 2005-04-16 2199 } while (retries < 3 &&
^1da177e4c3f41 Linus Torvalds 2005-04-16 2200 (!scsi_status_is_good(the_result) ||
464a00c9e0ad45 Hannes Reinecke 2021-04-27 2201 (scsi_status_is_check_condition(the_result) &&
^1da177e4c3f41 Linus Torvalds 2005-04-16 2202 sense_valid && sshdr.sense_key == UNIT_ATTENTION)));
^1da177e4c3f41 Linus Torvalds 2005-04-16 2203
464a00c9e0ad45 Hannes Reinecke 2021-04-27 2204 if (!scsi_status_is_check_condition(the_result)) {
^1da177e4c3f41 Linus Torvalds 2005-04-16 2205 /* no sense, TUR either succeeded or failed
^1da177e4c3f41 Linus Torvalds 2005-04-16 2206 * with a status error */
e73aec8247032e Martin K. Petersen 2007-02-27 2207 if(!spintime && !scsi_status_is_good(the_result)) {
ef61329db7b8b4 Hannes Reinecke 2014-10-24 2208 sd_print_result(sdkp, "Test Unit Ready failed",
ef61329db7b8b4 Hannes Reinecke 2014-10-24 2209 the_result);
e73aec8247032e Martin K. Petersen 2007-02-27 2210 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 2211 break;
^1da177e4c3f41 Linus Torvalds 2005-04-16 2212 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 2213
^1da177e4c3f41 Linus Torvalds 2005-04-16 2214 /*
^1da177e4c3f41 Linus Torvalds 2005-04-16 2215 * The device does not want the automatic start to be issued.
^1da177e4c3f41 Linus Torvalds 2005-04-16 2216 */
33dd6f92a1a7ad Matthew Wilcox 2009-02-20 2217 if (sdkp->device->no_start_on_add)
^1da177e4c3f41 Linus Torvalds 2005-04-16 2218 break;
^1da177e4c3f41 Linus Torvalds 2005-04-16 2219
33dd6f92a1a7ad Matthew Wilcox 2009-02-20 2220 if (sense_valid && sshdr.sense_key == NOT_READY) {
33dd6f92a1a7ad Matthew Wilcox 2009-02-20 2221 if (sshdr.asc == 4 && sshdr.ascq == 3)
^1da177e4c3f41 Linus Torvalds 2005-04-16 2222 break; /* manual intervention required */
33dd6f92a1a7ad Matthew Wilcox 2009-02-20 2223 if (sshdr.asc == 4 && sshdr.ascq == 0xb)
33dd6f92a1a7ad Matthew Wilcox 2009-02-20 2224 break; /* standby */
33dd6f92a1a7ad Matthew Wilcox 2009-02-20 2225 if (sshdr.asc == 4 && sshdr.ascq == 0xc)
33dd6f92a1a7ad Matthew Wilcox 2009-02-20 2226 break; /* unavailable */
505aa4b6a8834a Mahesh Rajashekhara 2018-04-17 2227 if (sshdr.asc == 4 && sshdr.ascq == 0x1b)
505aa4b6a8834a Mahesh Rajashekhara 2018-04-17 2228 break; /* sanitize in progress */
^1da177e4c3f41 Linus Torvalds 2005-04-16 2229 /*
^1da177e4c3f41 Linus Torvalds 2005-04-16 2230 * Issue command to spin up drive when not ready
^1da177e4c3f41 Linus Torvalds 2005-04-16 2231 */
^1da177e4c3f41 Linus Torvalds 2005-04-16 2232 if (!spintime) {
e73aec8247032e Martin K. Petersen 2007-02-27 2233 sd_printk(KERN_NOTICE, sdkp, "Spinning up disk...");
^1da177e4c3f41 Linus Torvalds 2005-04-16 2234 cmd[0] = START_STOP;
^1da177e4c3f41 Linus Torvalds 2005-04-16 2235 cmd[1] = 1; /* Return immediately */
^1da177e4c3f41 Linus Torvalds 2005-04-16 2236 memset((void *) &cmd[2], 0, 8);
^1da177e4c3f41 Linus Torvalds 2005-04-16 2237 cmd[4] = 1; /* Start spin cycle */
d2886ea368a677 Stefan Richter 2008-05-11 2238 if (sdkp->device->start_stop_pwr_cond)
d2886ea368a677 Stefan Richter 2008-05-11 2239 cmd[4] |= 1 << 4;
af16cd63d9d3b7 Mike Christie 2022-12-29 2240 scsi_execute_cmd(sdkp->device, cmd,
af16cd63d9d3b7 Mike Christie 2022-12-29 2241 REQ_OP_DRV_IN, NULL, 0,
0610959fbbca62 Mike Christie 2020-10-01 2242 SD_TIMEOUT, sdkp->max_retries,
af16cd63d9d3b7 Mike Christie 2022-12-29 2243 &exec_args);
4451e472627881 Alan Stern 2005-07-12 2244 spintime_expire = jiffies + 100 * HZ;
^1da177e4c3f41 Linus Torvalds 2005-04-16 2245 spintime = 1;
4451e472627881 Alan Stern 2005-07-12 2246 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 2247 /* Wait 1 second for next try */
^1da177e4c3f41 Linus Torvalds 2005-04-16 2248 msleep(1000);
3a1d0783ac2750 Michał Mirosław 2017-11-24 2249 printk(KERN_CONT ".");
4451e472627881 Alan Stern 2005-07-12 2250
4451e472627881 Alan Stern 2005-07-12 2251 /*
4451e472627881 Alan Stern 2005-07-12 2252 * Wait for USB flash devices with slow firmware.
4451e472627881 Alan Stern 2005-07-12 2253 * Yes, this sense key/ASC combination shouldn't
4451e472627881 Alan Stern 2005-07-12 2254 * occur here. It's characteristic of these devices.
4451e472627881 Alan Stern 2005-07-12 2255 */
4451e472627881 Alan Stern 2005-07-12 2256 } else if (sense_valid &&
4451e472627881 Alan Stern 2005-07-12 2257 sshdr.sense_key == UNIT_ATTENTION &&
4451e472627881 Alan Stern 2005-07-12 2258 sshdr.asc == 0x28) {
4451e472627881 Alan Stern 2005-07-12 2259 if (!spintime) {
4451e472627881 Alan Stern 2005-07-12 2260 spintime_expire = jiffies + 5 * HZ;
4451e472627881 Alan Stern 2005-07-12 2261 spintime = 1;
4451e472627881 Alan Stern 2005-07-12 2262 }
4451e472627881 Alan Stern 2005-07-12 2263 /* Wait 1 second for next try */
4451e472627881 Alan Stern 2005-07-12 2264 msleep(1000);
^1da177e4c3f41 Linus Torvalds 2005-04-16 2265 } else {
^1da177e4c3f41 Linus Torvalds 2005-04-16 2266 /* we don't understand the sense code, so it's
^1da177e4c3f41 Linus Torvalds 2005-04-16 2267 * probably pointless to loop */
^1da177e4c3f41 Linus Torvalds 2005-04-16 2268 if(!spintime) {
e73aec8247032e Martin K. Petersen 2007-02-27 2269 sd_printk(KERN_NOTICE, sdkp, "Unit Not Ready\n");
e73aec8247032e Martin K. Petersen 2007-02-27 2270 sd_print_sense_hdr(sdkp, &sshdr);
^1da177e4c3f41 Linus Torvalds 2005-04-16 2271 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 2272 break;
^1da177e4c3f41 Linus Torvalds 2005-04-16 2273 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 2274
4451e472627881 Alan Stern 2005-07-12 2275 } while (spintime && time_before_eq(jiffies, spintime_expire));
^1da177e4c3f41 Linus Torvalds 2005-04-16 2276
^1da177e4c3f41 Linus Torvalds 2005-04-16 2277 if (spintime) {
^1da177e4c3f41 Linus Torvalds 2005-04-16 2278 if (scsi_status_is_good(the_result))
3a1d0783ac2750 Michał Mirosław 2017-11-24 2279 printk(KERN_CONT "ready\n");
^1da177e4c3f41 Linus Torvalds 2005-04-16 2280 else
3a1d0783ac2750 Michał Mirosław 2017-11-24 2281 printk(KERN_CONT "not responding...\n");
^1da177e4c3f41 Linus Torvalds 2005-04-16 2282 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 2283 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 2284
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
next reply other threads:[~2023-12-06 17:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-06 17:05 kernel test robot [this message]
-- strict thread matches above, loose matches on Subject: below --
2024-11-14 23:21 drivers/scsi/sd.c:2183:7-17: WARNING: Unsigned expression compared with zero: the_result > 0 kernel test robot
2024-11-30 4:55 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=202312070013.1Fps4LEH-lkp@intel.com \
--to=lkp@intel.com \
--cc=julia.lawall@inria.fr \
--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.