diff mbox series

[bpf-next,1/2] tools/bpftool: re-organize newline printing for map listing

Message ID 20190416085920.7292-2-bhole_prashant_q7@lab.ntt.co.jp
State Changes Requested
Delegated to: BPF Maintainers
Headers show
Series show btf id in bpftool map list | expand

Commit Message

Prashant Bhole April 16, 2019, 8:59 a.m. UTC
Let's move the final newline printing in show_map_close_plain() at
the end of the function because it looks correct and consistent with
prog.c. Also let's do related changes for the line which prints
pinned file name.

Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
---
 tools/bpf/bpftool/map.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Quentin Monnet April 16, 2019, 9:22 a.m. UTC | #1
2019-04-16 17:59 UTC+0900 ~ Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
> Let's move the final newline printing in show_map_close_plain() at
> the end of the function because it looks correct and consistent with
> prog.c. Also let's do related changes for the line which prints
> pinned file name.
> 
> Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
> ---
>   tools/bpf/bpftool/map.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/bpf/bpftool/map.c b/tools/bpf/bpftool/map.c
> index e96903078991..cda0f27fa895 100644
> --- a/tools/bpf/bpftool/map.c
> +++ b/tools/bpf/bpftool/map.c
> @@ -604,15 +604,16 @@ static int show_map_close_plain(int fd, struct bpf_map_info *info)
>   	}
>   	close(fd);
>   
> -	printf("\n");
>   	if (!hash_empty(map_table.table)) {
>   		struct pinned_obj *obj;
>   
>   		hash_for_each_possible(map_table.table, obj, hash, info->id) {
>   			if (obj->id == info->id)
> -				printf("\tpinned %s\n", obj->path);
> +				printf("\n\tpinned %s", obj->path);
>   		}
>   	}
> +
> +	printf("\n");
>   	return 0;
>   }
>   
> 

Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
Thanks!
Song Liu April 16, 2019, 8:30 p.m. UTC | #2
> On Apr 16, 2019, at 2:22 AM, Quentin Monnet <quentin.monnet@netronome.com> wrote:
> 
> 2019-04-16 17:59 UTC+0900 ~ Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
>> Let's move the final newline printing in show_map_close_plain() at
>> the end of the function because it looks correct and consistent with
>> prog.c. Also let's do related changes for the line which prints
>> pinned file name.
>> Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>

Acked-by: Song Liu <songliubraving@fb.com>

>> ---
>>  tools/bpf/bpftool/map.c | 5 +++--
>>  1 file changed, 3 insertions(+), 2 deletions(-)
>> diff --git a/tools/bpf/bpftool/map.c b/tools/bpf/bpftool/map.c
>> index e96903078991..cda0f27fa895 100644
>> --- a/tools/bpf/bpftool/map.c
>> +++ b/tools/bpf/bpftool/map.c
>> @@ -604,15 +604,16 @@ static int show_map_close_plain(int fd, struct bpf_map_info *info)
>>  	}
>>  	close(fd);
>>  -	printf("\n");
>>  	if (!hash_empty(map_table.table)) {
>>  		struct pinned_obj *obj;
>>    		hash_for_each_possible(map_table.table, obj, hash, info->id) {
>>  			if (obj->id == info->id)
>> -				printf("\tpinned %s\n", obj->path);
>> +				printf("\n\tpinned %s", obj->path);
>>  		}
>>  	}
>> +
>> +	printf("\n");
>>  	return 0;
>>  }
>>  
> 
> Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
> Thanks!
diff mbox series

Patch

diff --git a/tools/bpf/bpftool/map.c b/tools/bpf/bpftool/map.c
index e96903078991..cda0f27fa895 100644
--- a/tools/bpf/bpftool/map.c
+++ b/tools/bpf/bpftool/map.c
@@ -604,15 +604,16 @@  static int show_map_close_plain(int fd, struct bpf_map_info *info)
 	}
 	close(fd);
 
-	printf("\n");
 	if (!hash_empty(map_table.table)) {
 		struct pinned_obj *obj;
 
 		hash_for_each_possible(map_table.table, obj, hash, info->id) {
 			if (obj->id == info->id)
-				printf("\tpinned %s\n", obj->path);
+				printf("\n\tpinned %s", obj->path);
 		}
 	}
+
+	printf("\n");
 	return 0;
 }