xfs_quota: fix unsigned int id comparisons
PATCH 1/1 xfs_quota: fix unsigned int id comparisons
From: Darrick J. Wong <[email protected]>
Fix compiler warnings about unsigned int comparisons by replacing them with an explicit check for the one possible invalid value (-1U). id_from_string sets exitcode to nonzero when it sees this value, so the call sites don't have to do that.
Coverity-id: 1463855, 1463856, 1463857
--- quota/edit.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
quota/edit.c +11 -11
@@ -307,11 +307,11 @@ limit_f( id =id_from_string (name, type); -if (id >=0 ) -set_limits (id, type, mask, fs_path->fs_name, - &bsoft, &bhard, &isoft, &ihard, &rtbsoft, &rtbhard); -else - exitcode =-1 ; +if (id ==-1 ) +return 0 ; + +set_limits (id, type, mask, fs_path->fs_name, + &bsoft, &bhard, &isoft, &ihard, &rtbsoft, &rtbhard);return 0 ; }
@@ -545,9 +545,10 @@ timer_f(if (name) id =id_from_string (name, type); -if (id >=0 ) -set_timer (id, type, mask, fs_path->fs_name, value); +if (id ==-1 ) +return 0 ; +set_timer (id, type, mask, fs_path->fs_name, value);return 0 ; }
@@ -642,11 +643,10 @@ warn_f( } id =id_from_string (name, type); -if (id >=0 ) -set_warnings (id, type, mask, fs_path->fs_name, value); -else - exitcode =-1 ; +if (id ==-1 ) +return 0 ; +set_warnings (id, type, mask, fs_path->fs_name, value);return 0 ; }
Quoted 6 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
Fix compiler warnings about unsigned int comparisons by replacing them with an explicit check for the one possible invalid value (-1U).
id_from_stringsets exitcode to nonzero when it sees this value, so the call sites don't have to do that.
[and skip exitcode setting because that happens in id_from_string()]
Thanks for fixing this, now let's see if it's enough for Coverity :)
Quoted 59 lines
Coverity-id: 1463855, 1463856, 1463857
Fixes 67a73d6139d0 ("xfs_quota: refactor code to generate id from name")Fixes 36dc471cc9bb ("xfs_quota: allow individual timer extension")Signed-off-by Darrick J. Wong <[email protected]>--- quota/edit.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)quota/edit.c +11
-11@@ -307,11 +307,11 @@ limit_f( id =id_from_string (name, type); -if (id >=0 ) -set_limits (id, type, mask, fs_path->fs_name, - &bsoft, &bhard, &isoft, &ihard, &rtbsoft, &rtbhard); -else - exitcode =-1 ; +if (id ==-1 ) +return 0 ; + +set_limits (id, type, mask, fs_path->fs_name, + &bsoft, &bhard, &isoft, &ihard, &rtbsoft, &rtbhard);return 0 ; }@@ -545,9 +545,10 @@ timer_f(if (name) id =id_from_string (name, type); -if (id >=0 ) -set_timer (id, type, mask, fs_path->fs_name, value); +if (id ==-1 ) +return 0 ; +set_timer (id, type, mask, fs_path->fs_name, value);return 0 ; }@@ -642,11 +643,10 @@ warn_f( } id =id_from_string (name, type); -if (id >=0 ) -set_warnings (id, type, mask, fs_path->fs_name, value); -else - exitcode =-1 ; +if (id ==-1 ) +return 0 ; +set_warnings (id, type, mask, fs_path->fs_name, value);return 0 ; }