~ubuntu-branches/ubuntu/vivid/parted/vivid

« back to all changes in this revision

Viewing changes to libparted/cs/natmath.c

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2014-07-21 10:23:16 UTC
  • mfrom: (7.2.32 sid)
  • Revision ID: package-import@ubuntu.com-20140721102316-jsyv3yzmbo8vlde5
Tags: 3.1-3
Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
    libparted - a library for manipulating disk partitions
3
 
    Copyright (C) 2000, 2007-2010 Free Software Foundation, Inc.
 
3
    Copyright (C) 2000, 2007-2012 Free Software Foundation, Inc.
4
4
 
5
5
    This program is free software; you can redistribute it and/or modify
6
6
    it under the terms of the GNU General Public License as published by
102
102
PedSector
103
103
ped_greatest_common_divisor (PedSector a, PedSector b)
104
104
{
105
 
        PED_ASSERT (a >= 0, return 0);
106
 
        PED_ASSERT (b >= 0, return 0);
 
105
        PED_ASSERT (a >= 0);
 
106
        PED_ASSERT (b >= 0);
107
107
 
108
108
        /* Put the arguments in the "right" format.  (Recursive calls made by
109
109
         * this function are always in the right format.)
127
127
int
128
128
ped_alignment_init (PedAlignment* align, PedSector offset, PedSector grain_size)
129
129
{
130
 
        PED_ASSERT (align != NULL, return 0);
 
130
        PED_ASSERT (align != NULL);
131
131
 
132
132
        if (grain_size < 0)
133
133
                return 0;
196
196
 *      gcd = greatest common divisor of a and b
197
197
 *      gcd = x*a + y*b
198
198
 */
199
 
static EuclidTriple
 
199
static EuclidTriple _GL_ATTRIBUTE_PURE
200
200
extended_euclid (int a, int b)
201
201
{
202
202
        EuclidTriple    result;
340
340
/* This function returns the sector closest to "sector" that lies inside
341
341
 * geom and satisfies the alignment constraint.
342
342
 */
343
 
static PedSector
 
343
static PedSector _GL_ATTRIBUTE_PURE
344
344
_closest_inside_geometry (const PedAlignment* align, const PedGeometry* geom,
345
345
                          PedSector sector)
346
346
{
347
 
        PED_ASSERT (align != NULL, return -1);
 
347
        PED_ASSERT (align != NULL);
348
348
 
349
349
        if (!align->grain_size) {
350
350
                if (ped_alignment_is_aligned (align, geom, sector)
381
381
{
382
382
        PedSector       result;
383
383
 
384
 
        PED_ASSERT (align != NULL, return -1);
 
384
        PED_ASSERT (align != NULL);
385
385
 
386
386
        if (!align->grain_size)
387
387
                result = align->offset;
409
409
{
410
410
        PedSector       result;
411
411
 
412
 
        PED_ASSERT (align != NULL, return -1);
 
412
        PED_ASSERT (align != NULL);
413
413
 
414
414
        if (!align->grain_size)
415
415
                result = align->offset;
448
448
ped_alignment_align_nearest (const PedAlignment* align, const PedGeometry* geom,
449
449
                             PedSector sector)
450
450
{
451
 
        PED_ASSERT (align != NULL, return -1);
 
451
        PED_ASSERT (align != NULL);
452
452
 
453
453
        return closest (sector, ped_alignment_align_up (align, geom, sector),
454
454
                        ped_alignment_align_down (align, geom, sector));