From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga09.intel.com ([134.134.136.24]:26055 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751208AbdLFUKQ (ORCPT ); Wed, 6 Dec 2017 15:10:16 -0500 Date: Wed, 6 Dec 2017 13:10:14 -0700 From: Ross Zwisler Subject: Re: [xfsprogs PATCH v2 1/3] xfs_io: fix compiler warnings in getfsmap code Message-ID: <20171206201014.GA27401@linux.intel.com> References: <20171205235651.17102-1-ross.zwisler@linux.intel.com> <20171205235651.17102-2-ross.zwisler@linux.intel.com> <20171206002743.GC5858@dastard> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20171206002743.GC5858@dastard> Sender: fstests-owner@vger.kernel.org Content-Transfer-Encoding: quoted-printable To: Dave Chinner Cc: Ross Zwisler , linux-xfs , linux-nvdimm , fstests , Jan Kara , Dan Williams , "Darrick J . Wong" List-ID: On Wed, Dec 06, 2017 at 11:27:43AM +1100, Dave Chinner wrote: > On Tue, Dec 05, 2017 at 04:56:49PM -0700, Ross Zwisler wrote: > > I recently upgraded my compiler from > > gcc (GCC) 6.4.1 20170727 (Red Hat 6.4.1-1) > > to > > gcc (GCC) 7.2.1 20170915 (Red Hat 7.2.1-2) > > and started getting a bunch of compiler warnings in io/fsmap.c: > >=20 > > fsmap.c: In function =E2=80=98fsmap_f=E2=80=99: > > fsmap.c:228:40: warning: =E2=80=98%lld=E2=80=99 directive output ma= y be truncated writing > > between 1 and 17 bytes into a region of size between 12 and 28 > > [-Wformat-truncation=3D] > > snprintf(bbuf, sizeof(bbuf), "[%lld..%lld]:", > > ^~~~ > > fsmap.c:228:32: note: directive argument in the range [0, 360287970= 18963967] > > snprintf(bbuf, sizeof(bbuf), "[%lld..%lld]:", > > ^~~~~~~~~~~~~~~ > > fsmap.c:228:3: note: =E2=80=98snprintf=E2=80=99 output between 8 an= d 40 bytes into a > > destination of size 32 > > snprintf(bbuf, sizeof(bbuf), "[%lld..%lld]:", > > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > (long long)BTOBBT(p->fmr_physical), > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > (long long)BTOBBT(p->fmr_physical + p->fmr_length - 1)); > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > >=20 > > The issue is that 'bbuf' is only defined to be 32 characters wide, bu= t each > > signed long long can potentially print as many as 19 characters > > (9223372036854775807 is the max value). The format we're using for b= buf is > > "[%lld..%lld]:" which has 2 signed long longs plus 6 other characters > > "[..]:\0", which means it's possible we'll print up to 44 characters, > > overflowing our 32 char buffer. > >=20 > > Fix this by bumping all the buffer sizes in dump_map_verbose() to 64 > > characters. > >=20 > > Signed-off-by: Ross Zwisler > > Cc: Darrick J. Wong > > Fixes: 3fcab549a234 ("xfs_io: support the new getfsmap ioctl") >=20 > FYI, I posted a fix for this weeks ago. I think Eric has already > picked it up, but it hasn't been pushed out into the for-next branch > yet. I'm seeing similar new compiler warnings when compiling xfstests: write_log.c: In function =E2=80=98wlog_open=E2=80=99: write_log.c:124:37: warning: =E2=80=98%s=E2=80=99 directive writing up to= 1023 bytes into a region of size 224 [-Wformat-overflow=3D] "Could not open write_log - open(%s, %#o, %#o) failed: %s\n", ^~ write_log.c:124:4: note: directive argument in the range [1089, 2047] "Could not open write_log - open(%s, %#o, %#o) failed: %s\n", ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ etc. I don't see any patches posted that fix these, as of yet. As far as you = know, am I correct in thinking that these still need to be fixed? - Ross