fs/ntfs3: Add attrib operations
Hello Konstantin Komarov,
Commit be71b5cba2e6 ("fs/ntfs3: Add attrib operations") from Aug 13, 2021 (linux-next), leads to the following Smatch static checker warning:
fs/ntfs3/attrib.c:176 attr_allocate_clusters() error: we previously assumed 'pre_alloc' could be null (see line 167)
fs/ntfs3/attrib.c
160 int attr_allocate_clusters(struct ntfs_sb_info *sbi, struct runs_tree *run,
161 struct runs_tree *run_da, CLST vcn, CLST lcn,
162 CLST len, CLST *pre_alloc, enum ALLOCATE_OPT opt,
163 CLST *alen, const size_t fr, CLST *new_lcn,
164 CLST *new_len)
165 {
166 int err;
167 CLST flen, vcn0 = vcn, pre = pre_alloc ? *pre_alloc : 0;
168 size_t cnt = run->count;
169
170 for (;;) {
171 err = ntfs_look_for_free_space(sbi, lcn, len + pre, &lcn, &flen,
172 opt);
173
174 if (err == -ENOSPC && pre) {
175 pre = 0;--> 176 if (*pre_alloc)
I'm not sure why warnings from 2021 are showing up as new warnings but presumably this should be:
if (pre_alloc)
*pre_alloc = 0;
177 *pre_alloc = 0;
178 continue;
179 }
180
181 if (err == -ENOSPC && new_len && vcn - vcn0) {
182 /* Keep already allocated clusters. */
183 *alen = vcn - vcn0;This email is a free service from the Smatch-CI project [smatch.sf.net].
regards,
dan carpenter
Konstantin Komarov
maintainerQuoted 42 lines · Dan Carpenter
Hello Konstantin Komarov,
Commit
be71b5cba2e6("fs/ntfs3: Add attrib operations") from Aug 13, 2021 (linux-next), leads to the following Smatch static checker warning:fs/ntfs3/attrib.c:176 attr_allocate_clusters() error: we previously assumed 'pre_alloc' could be null (see line 167)
fs/ntfs3/attrib.c160 int attr_allocate_clusters(struct ntfs_sb_info *sbi, struct runs_tree *run, 161 struct runs_tree *run_da, CLST vcn, CLST lcn, 162 CLST len, CLST *pre_alloc, enum ALLOCATE_OPT opt, 163 CLST *alen, const size_t fr, CLST *new_lcn, 164 CLST *new_len) 165 { 166 int err; 167 CLST flen, vcn0 = vcn, pre = pre_alloc ? *pre_alloc : 0; 168 size_t cnt = run->count; 169 170 for (;;) { 171 err = ntfs_look_for_free_space(sbi, lcn, len + pre, &lcn, &flen, 172 opt); 173 174 if (err == -ENOSPC && pre) { 175 pre = 0;--> 176 if (
*pre_alloc)I'm not sure why warnings from 2021 are showing up as new warnings but presumably this should be:
if (pre_alloc) *pre_alloc = 0; 177 *pre_alloc = 0; 178 continue; 179 } 180 181 if (err == -ENOSPC && new_len && vcn - vcn0) { 182 /* Keep already allocated clusters. */ 183 *alen = vcn - vcn0;
Quoted 4 lines
This email is a free service from the Smatch-CI project [smatch.sf.net].
regards,
dan carpenter
Hello,
Thanks. The warning was fixed in the patch:
https://lore.kernel.org/ntfs3/[email protected]/
Regards,
Konstantin