Use signed values to compare absolute difference. The variables
authorbluhm <bluhm@openbsd.org>
Sun, 14 Jan 2018 00:33:09 +0000 (00:33 +0000)
committerbluhm <bluhm@openbsd.org>
Sun, 14 Jan 2018 00:33:09 +0000 (00:33 +0000)
fid and cfid are signed, so the FID_TO_VCO_FID() macro creates
signed results.  Keep the sign when passing to abs() although the
implicit conversions created the same binary.
OK deraadt@

sys/arch/amd64/amd64/powernow-k8.c

index 0183c14..2f80234 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: powernow-k8.c,v 1.27 2017/12/09 16:39:54 fcambus Exp $ */
+/*     $OpenBSD: powernow-k8.c,v 1.28 2018/01/14 00:33:09 bluhm Exp $ */
 /*
  * Copyright (c) 2004 Martin VĂ©giard.
  * Copyright (c) 2004-2005 Bruno Ducrot
@@ -231,7 +231,7 @@ k8pnow_transition(struct k8pnow_cpu_state *cstate, int level)
 
        /* Phase 2: change to requested core frequency */
        if (cfid != fid) {
-               u_int vco_fid, vco_cfid;
+               int vco_fid, vco_cfid;
 
                vco_fid = FID_TO_VCO_FID(fid);
                vco_cfid = FID_TO_VCO_FID(cfid);