* [PATCH] nfacct: correct regressions in v1.0.1 @ 2013-03-05 12:47 Mr Dash Four 2013-03-05 13:59 ` Pablo Neira Ayuso 0 siblings, 1 reply; 6+ messages in thread From: Mr Dash Four @ 2013-03-05 12:47 UTC (permalink / raw) To: Pablo Neira Ayuso; +Cc: Netfilter Core Team This patch fixes regressions present in v1.0.1, introduced as a result of commit d17c772c98057b2cc0118274605d292809ff6b1e. Signed-off-by: Mr Dash Four <mr.dash.four@googlemail.com> --- src/nfacct.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/nfacct.c b/src/nfacct.c index 4ce817d..21d4df8 100644 --- a/src/nfacct.c +++ b/src/nfacct.c @@ -218,7 +218,8 @@ static int nfacct_cmd_list(int argc, char *argv[]) return 0; } -static int _nfacct_cmd_add(char *name, int pkts, int bytes) +static int _nfacct_cmd_add(char *name, + long long unsigned pkts, long long unsigned bytes) { struct mnl_socket *nl; char buf[MNL_SOCKET_BUFFER_SIZE]; @@ -536,7 +537,7 @@ static int nfacct_cmd_restore(int argc, char *argv[]) return -1; } *semicolon = 0; - ret = sscanf(buffer, "{ pkts = %lu, bytes = %lu } = %s", + ret = sscanf(buffer, "{ pkts = %llu, bytes = %llu } = %s", &pkts, &bytes, name); if (ret != 3) { nfacct_perror("error reading input"); ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] nfacct: correct regressions in v1.0.1 2013-03-05 12:47 [PATCH] nfacct: correct regressions in v1.0.1 Mr Dash Four @ 2013-03-05 13:59 ` Pablo Neira Ayuso 2013-03-05 18:40 ` Mr Dash Four 2013-03-05 18:40 ` [PATCH] libnetfilter_acct: use PRIu64 and remove unnecessary cast Mr Dash Four 0 siblings, 2 replies; 6+ messages in thread From: Pablo Neira Ayuso @ 2013-03-05 13:59 UTC (permalink / raw) To: Mr Dash Four; +Cc: Netfilter Core Team On Tue, Mar 05, 2013 at 12:47:51PM +0000, Mr Dash Four wrote: > This patch fixes regressions present in v1.0.1, introduced as a result of > commit d17c772c98057b2cc0118274605d292809ff6b1e. > > Signed-off-by: Mr Dash Four <mr.dash.four@googlemail.com> > --- > src/nfacct.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/src/nfacct.c b/src/nfacct.c > index 4ce817d..21d4df8 100644 > --- a/src/nfacct.c > +++ b/src/nfacct.c > @@ -218,7 +218,8 @@ static int nfacct_cmd_list(int argc, char *argv[]) > return 0; > } > > -static int _nfacct_cmd_add(char *name, int pkts, int bytes) > +static int _nfacct_cmd_add(char *name, > + long long unsigned pkts, long long unsigned bytes) those are still signed, should be unsigned. > { > struct mnl_socket *nl; > char buf[MNL_SOCKET_BUFFER_SIZE]; > @@ -536,7 +537,7 @@ static int nfacct_cmd_restore(int argc, char *argv[]) > return -1; > } > *semicolon = 0; > - ret = sscanf(buffer, "{ pkts = %lu, bytes = %lu } = %s", > + ret = sscanf(buffer, "{ pkts = %llu, bytes = %llu } = %s", Better use %"PRIu64" given that we're using uint64_t. I have applied a patch based on yours. Thanks. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] nfacct: correct regressions in v1.0.1 2013-03-05 13:59 ` Pablo Neira Ayuso @ 2013-03-05 18:40 ` Mr Dash Four 2013-03-05 18:40 ` [PATCH] libnetfilter_acct: use PRIu64 and remove unnecessary cast Mr Dash Four 1 sibling, 0 replies; 6+ messages in thread From: Mr Dash Four @ 2013-03-05 18:40 UTC (permalink / raw) Cc: Netfilter Core Team >> -static int _nfacct_cmd_add(char *name, int pkts, int bytes) >> +static int _nfacct_cmd_add(char *name, >> + long long unsigned pkts, long long unsigned bytes) >> > > those are still signed, should be unsigned. > Noted. >> - ret = sscanf(buffer, "{ pkts = %lu, bytes = %lu } = %s", >> + ret = sscanf(buffer, "{ pkts = %llu, bytes = %llu } = %s", >> > > Better use %"PRIu64" given that we're using uint64_t. > You learn something new every day. If this is indeed the case, then another patch coming up in a minute. > I have applied a patch based on yours. > Thanks. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] libnetfilter_acct: use PRIu64 and remove unnecessary cast 2013-03-05 13:59 ` Pablo Neira Ayuso 2013-03-05 18:40 ` Mr Dash Four @ 2013-03-05 18:40 ` Mr Dash Four 2013-03-15 11:47 ` Pablo Neira Ayuso 1 sibling, 1 reply; 6+ messages in thread From: Mr Dash Four @ 2013-03-05 18:40 UTC (permalink / raw) To: Pablo Neira Ayuso; +Cc: Netfilter Core Team This patch corrects all nfacct_snprintf_* functions to use PRIu64, given that we are using uint64_t type variables and also removes the unnecessary casts. Signed-off-by: Mr Dash Four <mr.dash.four@googlemail.com> --- src/libnetfilter_acct.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/libnetfilter_acct.c b/src/libnetfilter_acct.c index 0abaeac..ba89e2d 100644 --- a/src/libnetfilter_acct.c +++ b/src/libnetfilter_acct.c @@ -13,6 +13,7 @@ #include <endian.h> #include <stdlib.h> #include <string.h> +#include <inttypes.h> #include <libmnl/libmnl.h> #include <linux/netfilter/nfnetlink.h> @@ -235,10 +236,8 @@ nfacct_snprintf_plain(char *buf, size_t rem, struct nfacct *nfacct, if (flags & NFACCT_SNPRINTF_F_FULL) { ret = snprintf(buf, rem, - "{ pkts = %.20llu, bytes = %.20llu } = %s;", - (unsigned long long) + "{ pkts = %.20"PRIu64", bytes = %.20"PRIu64" } = %s;", nfacct_attr_get_u64(nfacct, NFACCT_ATTR_PKTS), - (unsigned long long) nfacct_attr_get_u64(nfacct, NFACCT_ATTR_BYTES), nfacct_attr_get_str(nfacct, NFACCT_ATTR_NAME)); } else { @@ -296,12 +295,10 @@ nfacct_snprintf_xml(char *buf, size_t rem, struct nfacct *nfacct, ret = snprintf(buf, rem, "<obj><name>%s</name>" - "<pkts>%.20llu</pkts>" - "<bytes>%.20llu</bytes>", + "<pkts>%.20"PRIu64"</pkts>" + "<bytes>%.20"PRIu64"</bytes>", nfacct_attr_get_str(nfacct, NFACCT_ATTR_NAME), - (unsigned long long) nfacct_attr_get_u64(nfacct, NFACCT_ATTR_BYTES), - (unsigned long long) nfacct_attr_get_u64(nfacct, NFACCT_ATTR_PKTS)); BUFFER_SIZE(ret, size, rem, offset); ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] libnetfilter_acct: use PRIu64 and remove unnecessary cast 2013-03-05 18:40 ` [PATCH] libnetfilter_acct: use PRIu64 and remove unnecessary cast Mr Dash Four @ 2013-03-15 11:47 ` Pablo Neira Ayuso 2013-03-16 14:06 ` Mr Dash Four 0 siblings, 1 reply; 6+ messages in thread From: Pablo Neira Ayuso @ 2013-03-15 11:47 UTC (permalink / raw) To: Mr Dash Four; +Cc: Netfilter developer mailing list On Tue, Mar 05, 2013 at 06:40:39PM +0000, Mr Dash Four wrote: > This patch corrects all nfacct_snprintf_* functions to use PRIu64, > given that we are using uint64_t type variables and also removes > the unnecessary casts. Applied, thanks. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] libnetfilter_acct: use PRIu64 and remove unnecessary cast 2013-03-15 11:47 ` Pablo Neira Ayuso @ 2013-03-16 14:06 ` Mr Dash Four 0 siblings, 0 replies; 6+ messages in thread From: Mr Dash Four @ 2013-03-16 14:06 UTC (permalink / raw) To: Netfilter developer mailing list Pablo Neira Ayuso wrote: > On Tue, Mar 05, 2013 at 06:40:39PM +0000, Mr Dash Four wrote: > >> This patch corrects all nfacct_snprintf_* functions to use PRIu64, >> given that we are using uint64_t type variables and also removes >> the unnecessary casts. >> > > Applied, thanks. > Applied where Pablo? I can't see any commits done on the main libnetfilter_acct tree for 13 days? ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-03-16 14:06 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-03-05 12:47 [PATCH] nfacct: correct regressions in v1.0.1 Mr Dash Four 2013-03-05 13:59 ` Pablo Neira Ayuso 2013-03-05 18:40 ` Mr Dash Four 2013-03-05 18:40 ` [PATCH] libnetfilter_acct: use PRIu64 and remove unnecessary cast Mr Dash Four 2013-03-15 11:47 ` Pablo Neira Ayuso 2013-03-16 14:06 ` Mr Dash Four
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).