[PATCH 05/12] quota: Add missing prefixes to struct field names
Dmitry V. Levin
ldv at altlinux.org
Tue Sep 27 08:29:47 UTC 2016
On Wed, Sep 21, 2016 at 06:11:28AM +0300, Eugene Syromyatnikov wrote:
> * quota.c (decode_cmd_data): Print field names in accordance with their
> definition.
> ---
> quota.c | 191 ++++++++++++++++++++++++++++++++-------------------------------
> 1 file changed, 98 insertions(+), 93 deletions(-)
>
> diff --git a/quota.c b/quota.c
> index 68f8a79..1e1597f 100644
> --- a/quota.c
> +++ b/quota.c
> @@ -237,16 +237,16 @@ decode_cmd_data(struct tcb *tcp, uint32_t id, uint32_t cmd, unsigned long data)
>
> if (umove_or_printaddr(tcp, data, &dq))
> break;
> - tprintf("{bhardlimit=%" PRIu64 ", ", dq.dqb_bhardlimit);
> - tprintf("bsoftlimit=%" PRIu64 ", ", dq.dqb_bsoftlimit);
> - tprintf("curspace=%" PRIu64 ", ", dq.dqb_curspace);
> - tprintf("ihardlimit=%" PRIu64 ", ", dq.dqb_ihardlimit);
> - tprintf("isoftlimit=%" PRIu64 ", ", dq.dqb_isoftlimit);
> - tprintf("curinodes=%" PRIu64 ", ", dq.dqb_curinodes);
> + tprintf("{dqb_bhardlimit=%" PRIu64 ", ", dq.dqb_bhardlimit);
> + tprintf("dqb_bsoftlimit=%" PRIu64 ", ", dq.dqb_bsoftlimit);
> + tprintf("dqb_curspace=%" PRIu64 ", ", dq.dqb_curspace);
> + tprintf("dqb_ihardlimit=%" PRIu64 ", ", dq.dqb_ihardlimit);
> + tprintf("dqb_isoftlimit=%" PRIu64 ", ", dq.dqb_isoftlimit);
> + tprintf("dqb_curinodes=%" PRIu64 ", ", dq.dqb_curinodes);
> if (!abbrev(tcp)) {
> - tprintf("btime=%" PRIu64 ", ", dq.dqb_btime);
> - tprintf("itime=%" PRIu64 ", ", dq.dqb_itime);
> - tprints("valid=");
> + tprintf("dqb_btime=%" PRIu64 ", ", dq.dqb_btime);
> + tprintf("dqb_itime=%" PRIu64 ", ", dq.dqb_itime);
> + tprints("dqb_valid=");
> printflags(if_dqblk_valid,
> dq.dqb_valid, "QIF_???");
> tprints("}");
> @@ -267,19 +267,19 @@ decode_cmd_data(struct tcb *tcp, uint32_t id, uint32_t cmd, unsigned long data)
>
> if (umove_or_printaddr(tcp, data, &dq))
> break;
> - tprintf("{bhardlimit=%" PRIu64 ", ", dq.dqb_bhardlimit);
> - tprintf("bsoftlimit=%" PRIu64 ", ", dq.dqb_bsoftlimit);
> - tprintf("curspace=%" PRIu64 ", ", dq.dqb_curspace);
> - tprintf("ihardlimit=%" PRIu64 ", ", dq.dqb_ihardlimit);
> - tprintf("isoftlimit=%" PRIu64 ", ", dq.dqb_isoftlimit);
> - tprintf("curinodes=%" PRIu64 ", ", dq.dqb_curinodes);
> + tprintf("{dqb_bhardlimit=%" PRIu64 ", ", dq.dqb_bhardlimit);
> + tprintf("dqb_bsoftlimit=%" PRIu64 ", ", dq.dqb_bsoftlimit);
> + tprintf("dqb_curspace=%" PRIu64 ", ", dq.dqb_curspace);
> + tprintf("dqb_ihardlimit=%" PRIu64 ", ", dq.dqb_ihardlimit);
> + tprintf("dqb_isoftlimit=%" PRIu64 ", ", dq.dqb_isoftlimit);
> + tprintf("dqb_curinodes=%" PRIu64 ", ", dq.dqb_curinodes);
> if (!abbrev(tcp)) {
> - tprintf("btime=%" PRIu64 ", ", dq.dqb_btime);
> - tprintf("itime=%" PRIu64 ", ", dq.dqb_itime);
> - tprints("valid=");
> + tprintf("dqb_btime=%" PRIu64 ", ", dq.dqb_btime);
> + tprintf("dqb_itime=%" PRIu64 ", ", dq.dqb_itime);
> + tprints("dqb_valid=");
> printflags(if_dqblk_valid,
> dq.dqb_valid, "QIF_???");
> - tprintf(", id=%u}", dq.dqb_id);
> + tprintf(", dqb_id=%u}", dq.dqb_id);
> } else
> tprintf("id=%u, ...}", dq.dqb_id);
This approach is error-prone, as the last line clearly demonstrates.
I've introduced a macro to make it less prone to such errors.
--
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20160927/ecaeeb8c/attachment.bin>
More information about the Strace-devel
mailing list