OSDN Git Service

selftests/intel_pstate: Fix warning on loop index overflow
authorStafford Horne <shorne@gmail.com>
Wed, 11 Jan 2017 15:16:05 +0000 (00:16 +0900)
committerShuah Khan <shuahkh@osg.samsung.com>
Thu, 19 Jan 2017 17:30:34 +0000 (10:30 -0700)
The build was showing the warning:
 aperf.c:60:27: warning: iteration 2147483647 invokes undefined behavior
 [-Waggressive-loop-optimizations]
  for (i=0; i<0x8fffffff; i++) {

This change sets i, cpu and fd to unsigned int as they should not need
to be signed.

Cc: Prarit Bhargava <prarit@redhat.com>
Signed-off-by: Stafford Horne <shorne@gmail.com>
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
tools/testing/selftests/intel_pstate/aperf.c

index 6046e18..cd72f3d 100644 (file)
@@ -14,7 +14,7 @@ void usage(char *name) {
 }
 
 int main(int argc, char **argv) {
-       int i, cpu, fd;
+       unsigned int i, cpu, fd;
        char msr_file_name[64];
        long long tsc, old_tsc, new_tsc;
        long long aperf, old_aperf, new_aperf;