projects/pwm

changeset 4:b5c4267a7182

Fix check for successful deletion of a empty group

A return value of NULL means that there is no empty group of that name.
Improve the error message.
author Guido Berhoerster <guido+pwm@berhoerster.name>
date Sun Feb 05 13:30:31 2017 +0100 (2017-02-05)
parents 1cc98a5677d9
children 0b1bce8db371
files cmd.c pwfile.c
line diff
     1.1 --- a/cmd.c	Sat Feb 04 22:06:15 2017 +0100
     1.2 +++ b/cmd.c	Sun Feb 05 13:30:31 2017 +0100
     1.3 @@ -440,7 +440,7 @@
     1.4  	}
     1.5  
     1.6  	if (pwfile_remove_group(ctx, argv[1]) != 0) {
     1.7 -		fprintf(stderr, "group \"%s\" does not exist\n", argv[1]);
     1.8 +		fprintf(stderr, "there is no empty group \"%s\"\n", argv[1]);
     1.9  		return (CMD_ERR);
    1.10  	}
    1.11  
     2.1 --- a/pwfile.c	Sat Feb 04 22:06:15 2017 +0100
     2.2 +++ b/pwfile.c	Sun Feb 05 13:30:31 2017 +0100
     2.3 @@ -692,7 +692,7 @@
     2.4  	struct pws3_field *empty_group_field;
     2.5  
     2.6  	empty_group_field = pws3_file_remove_empty_group(ctx->file, group);
     2.7 -	if (empty_group_field != NULL) {
     2.8 +	if (empty_group_field == NULL) {
     2.9  		return (-1);
    2.10  	}
    2.11  	pws3_field_destroy(empty_group_field);