From owner-svn-src-head@freebsd.org Sat Apr 30 19:58:55 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7BF71B224B2; Sat, 30 Apr 2016 19:58:55 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3EB1B1ED3; Sat, 30 Apr 2016 19:58:55 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u3UJws23044934; Sat, 30 Apr 2016 19:58:54 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u3UJwsOo044932; Sat, 30 Apr 2016 19:58:54 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201604301958.u3UJwsOo044932@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Sat, 30 Apr 2016 19:58:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r298861 - in head/sbin: fdisk fdisk_pc98 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 30 Apr 2016 19:58:55 -0000 Author: pfg Date: Sat Apr 30 19:58:54 2016 New Revision: 298861 URL: https://svnweb.freebsd.org/changeset/base/298861 Log: fdisk: drop unused macro and make use of roundup()/rounddown(). Modified: head/sbin/fdisk/fdisk.c head/sbin/fdisk_pc98/fdisk.c Modified: head/sbin/fdisk/fdisk.c ============================================================================== --- head/sbin/fdisk/fdisk.c Sat Apr 30 19:50:59 2016 (r298860) +++ head/sbin/fdisk/fdisk.c Sat Apr 30 19:58:54 2016 (r298861) @@ -67,8 +67,6 @@ static char lbuf[LBUF]; #define Decimal(str, ans, tmp, maxval) if (decimal(str, &tmp, ans, maxval)) ans = tmp -#define RoundCyl(x) ((((x) + cylsecs - 1) / cylsecs) * cylsecs) - #define MAX_SEC_SIZE 2048 /* maximum section size that is supported */ #define MIN_SEC_SIZE 512 /* the sector size to start sensing at */ static int secsize = 0; /* the sensed sector size */ @@ -387,7 +385,7 @@ main(int argc, char *argv[]) partp->dp_typ = DOSPTYP_386BSD; partp->dp_flag = ACTIVE; partp->dp_start = dos_sectors; - partp->dp_size = (disksecs / dos_cylsecs) * dos_cylsecs - + partp->dp_size = rounddown(disksecs, dos_cylsecs) - dos_sectors; dos(partp); if (v_flag) @@ -540,11 +538,11 @@ init_sector0(unsigned long start) partp->dp_typ = DOSPTYP_386BSD; partp->dp_flag = ACTIVE; - start = ((start + dos_sectors - 1) / dos_sectors) * dos_sectors; + start = roundup(start, dos_sectors); if(start == 0) start = dos_sectors; partp->dp_start = start; - partp->dp_size = (disksecs / dos_cylsecs) * dos_cylsecs - start; + partp->dp_size = rounddown(disksecs, dos_cylsecs) - start; dos(partp); } @@ -1188,8 +1186,8 @@ process_partition(CMD *command) prev_partp->dp_size; } if (partp->dp_start % dos_sectors != 0) { - prev_head_boundary = partp->dp_start / - dos_sectors * dos_sectors; + prev_head_boundary = rounddown(partp->dp_start, + dos_sectors); partp->dp_start = prev_head_boundary + dos_sectors; } @@ -1203,15 +1201,15 @@ process_partition(CMD *command) if (command->args[3].arg_str != NULL) { if (strcmp(command->args[3].arg_str, "*") == 0) - partp->dp_size = ((disksecs / dos_cylsecs) * - dos_cylsecs) - partp->dp_start; + partp->dp_size = rounddown(disksecs, dos_cylsecs) - + partp->dp_start; else { partp->dp_size = str2sectors(command->args[3].arg_str); if (partp->dp_size == NO_DISK_SECTORS) break; } - prev_cyl_boundary = ((partp->dp_start + partp->dp_size) / - dos_cylsecs) * dos_cylsecs; + prev_cyl_boundary = rounddown(partp->dp_start + partp->dp_size, + dos_cylsecs); if (prev_cyl_boundary > partp->dp_start) partp->dp_size = prev_cyl_boundary - partp->dp_start; } else @@ -1235,7 +1233,7 @@ process_partition(CMD *command) * Adjust start upwards, if necessary, to fall on a head boundary. */ if (partp->dp_start % dos_sectors != 0) { - prev_head_boundary = partp->dp_start / dos_sectors * dos_sectors; + prev_head_boundary = rounddown(partp->dp_start, dos_sectors); if (max_end < dos_sectors || prev_head_boundary > max_end - dos_sectors) { /* @@ -1259,8 +1257,8 @@ process_partition(CMD *command) * Adjust size downwards, if necessary, to fall on a cylinder * boundary. */ - prev_cyl_boundary = - ((partp->dp_start + partp->dp_size) / dos_cylsecs) * dos_cylsecs; + prev_cyl_boundary = rounddown(partp->dp_start + partp->dp_size, + dos_cylsecs); if (prev_cyl_boundary > partp->dp_start) adj_size = prev_cyl_boundary - partp->dp_start; else { @@ -1451,7 +1449,7 @@ sanitize_partition(struct dos_partition * Adjust start upwards, if necessary, to fall on a head boundary. */ if (start % dos_sectors != 0) { - prev_head_boundary = start / dos_sectors * dos_sectors; + prev_head_boundary = rounddown(start, dos_sectors); if (max_end < dos_sectors || prev_head_boundary >= max_end - dos_sectors) { /* @@ -1468,7 +1466,7 @@ sanitize_partition(struct dos_partition * Adjust size downwards, if necessary, to fall on a cylinder * boundary. */ - prev_cyl_boundary = ((start + size) / dos_cylsecs) * dos_cylsecs; + prev_cyl_boundary = rounddown(start + size, dos_cylsecs); if (prev_cyl_boundary > start) size = prev_cyl_boundary - start; else { Modified: head/sbin/fdisk_pc98/fdisk.c ============================================================================== --- head/sbin/fdisk_pc98/fdisk.c Sat Apr 30 19:50:59 2016 (r298860) +++ head/sbin/fdisk_pc98/fdisk.c Sat Apr 30 19:58:54 2016 (r298861) @@ -63,8 +63,6 @@ static char lbuf[LBUF]; #define Decimal(str, ans, tmp) if (decimal(str, &tmp, ans)) ans = tmp #define String(str, ans, len) {char *z = ans; char **dflt = &z; if (string(str, dflt)) strncpy(ans, *dflt, len); } -#define RoundCyl(x) ((((x) + cylsecs - 1) / cylsecs) * cylsecs) - #define MAX_SEC_SIZE 2048 /* maximum section size that is supported */ #define MIN_SEC_SIZE 512 /* the sector size to start sensing at */ static int secsize = 0; /* the sensed sector size */