* Dan Carpenter <[email protected]> wrote: > Hello Tino Reichardt, > > The patch 0d59722ea777: "fs/jfs: TRIM support for JFS Filesystem" > from Aug 29, 2012, leads to the following static checker warning: > fs/jfs/jfs_dmap.c:1650 dbDiscardAG() > warn: check 'range_cnt' for negative values
I just compiled smatch from http://smatch.sourceforge.net/ and run the building of JFS with the C=1 and C=2 options. It seems no problem for this issue, but there are several others[1]. What is static checker should I run, to get the warning ? > > 1648 nblocks = bmp->db_agfree[agno]; > 1649 range_cnt = min_t(int, range_cnt, nblocks / minlen + 1); > ^^^ > Could we make this unsigned? The caller checks that minlen is >= 1 and > probably someone checks nblocks as well, but it's annoying to have to > audit this. Yes, unsigned should be fine, minlen can also be changed to u64 and nblocks should be >= 0 ... I have no idea why dn_agfree[MAXAG] is definded as s64 - Dave, du you know more about that? @ jfs_dmap.h: s64 dn_agfree[MAXAG]; /* per AG free count */ There are also 3 other variables, which could be used as u64 there ... or not? I am not sure about that... ;) I could also make a patch for it, but I have no idea about the checker... is it @ linux/scripts? Can you give me some hint? So I can check that min_t() issue myself ;) > 1650 totrim = kmalloc(sizeof(struct range2trim) * range_cnt, > GFP_NOFS); > 1651 if (totrim == NULL) { > 1652 jfs_error(bmp->db_ipbmap->i_sb, > 1653 "dbDiscardAG: no memory for trim array"); > 1654 IWRITE_UNLOCK(ipbmap); > 1655 return 0; > 1656 } [1] Errors from smatch, Dave - we should take a look @ it... http://www.mcmilk.de/projects/jfs-trim/jfs-smatch-errors.txt -- regards, TR ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Jfs-discussion mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/jfs-discussion
