Re: [PATCH v3] tools/bpf: Fix the wrong format specifier

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> The format specifier of "unsigned int" in printf() should be "%u", not
> "%d".

Would you like to add any tags (like “Fixes” and “Cc”) accordingly?


…
> ---
> Changes:
…
> v3:fix compile warninf

V3:
Fix a compilation warning?


…
> +++ b/tools/bpf/bpftool/xlated_dumper.c
> @@ -316,7 +316,7 @@ void dump_xlated_plain(struct dump_data *dd, void *buf, unsigned int len,
…
> -	unsigned int i;
> +	int i;

Please do not change the data type for the variable
if you would like to adjust a subsequent format string.


…
> @@ -415,7 +415,7 @@ void dump_xlated_for_graph(struct dump_data *dd, void *buf_start, void *buf_end,
>  			}
>  		}
>
> -		printf("%d: ", insn_off);
> +		printf("%u: ", insn_off);
>  		print_bpf_insn(&cbs, cur, true);
…

How do you think about to care more also for the return value from such a function call?
https://wiki.sei.cmu.edu/confluence/display/c/ERR33-C.+Detect+and+handle+standard+library+errors

Regards,
Markus





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux