[parted-devel] [PATCH 2/2] Fix end_input usage in do_resizepart

Phillip Susi phill at thesusis.net
Wed Apr 24 13:53:17 BST 2019


Wasn't there a standing project policy to delay variable definition
until its actually needed rather than always putting them at the start
of the function?  I think that's why it was where it was.  Also if I'm
reading adjust_end_if_iec() right, it will subtract one from the end
sector if the end_input is NULL.  We don't want that do we?

Brian C. Lane writes:

> It needs to be set to NULL, since it may not get set by the call to
> command_line_get_sector
> ---
>  parted/parted.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/parted/parted.c b/parted/parted.c
> index fe7c26d..39fdfef 100644
> --- a/parted/parted.c
> +++ b/parted/parted.c
> @@ -1548,6 +1548,7 @@ do_resizepart (PedDevice** dev, PedDisk** diskp)
>          PedGeometry             *range_end = NULL;
>          PedConstraint*          constraint;
>          int rc = 0;
> +        char*                   end_input = NULL;
>  
>          if (!disk) {
>                  disk = ped_disk_new (*dev);
> @@ -1568,8 +1569,7 @@ do_resizepart (PedDevice** dev, PedDisk** diskp)
>  
>          start = part->geom.start;
>          end = oldend = part->geom.end;
> -        char *end_input;
> -        if (!command_line_get_sector (_("End?"), *dev, &end, &range_end, &end_input))
> +        if (!command_line_get_sector (_("End?"), *dev, &end, &range_end, &end_input) )
>                  goto error;
>          _adjust_end_if_iec(&start, &end, range_end, end_input);
>          free(end_input);




More information about the parted-devel mailing list