Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1336515

Summary: cli: compiler warning format string
Product: [Community] GlusterFS Reporter: Kaleb KEITHLEY <kkeithle>
Component: cliAssignee: Muthu Vigneshwaran <mvignesh>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: mainlineCC: amukherj, bugs, jahernan, mvignesh, smohan
Target Milestone: ---Keywords: Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-10-08 08:45:59 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Kaleb KEITHLEY 2016-05-16 17:05:32 UTC
Description of problem:


Making all in firewalld
Making all in cli
Making all in src
  CC       cli.o
  CC       registry.o
  CC       input.o
  CC       cli-cmd.o
  CC       cli-rl.o
  CC       cli-cmd-global.o
  CC       cli-cmd-volume.o
  CC       cli-cmd-peer.o
  CC       cli-rpc-ops.o
  CC       cli-cmd-parser.o
  CC       cli-cmd-system.o
cli-rpc-ops.c: In function 'cli_populate_req_dict_for_delete':
cli-rpc-ops.c:9815:55: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'size_t {aka unsigned int}' [-Wformat=]
         ret = snprintf (key, sizeof (key), "snapname%lu", index);
                                                       ^
  CC       cli-cmd-misc.o
  CC       cli-xml-output.o
  CC       cli-quotad-client.o
  CC       cli-cmd-snapshot.o
  CCLD     gluster



Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 1 Muthu Vigneshwaran 2016-07-15 09:15:38 UTC
Hi,

In the function, size_t index is used, which can hold any array index. Depending on the implementation it can be unsigned char/short/int/long/long long.

I tried the same on Fedora, and the default compiler type is:

echo | gcc -E -xc -include 'stddef.h' - | grep size_t

Output is:
typedef long unsigned int size_t

So, the correct format specifier being %lu is used and it does not throw any warning.

I think we should close the bug as this is more compiler dependent.

Comment 2 Kaleb KEITHLEY 2016-07-15 12:53:18 UTC
Did you try compiling on 32-bit Fedora?

%zu is the correct format string for variables of type size_t. Please see the man page for printf(3)

Comment 3 Atin Mukherjee 2018-10-07 13:15:11 UTC
Xavi - does https://review.gluster.org/#/c/21276/ address it? Could you check?

Comment 4 Xavi Hernandez 2018-10-08 08:45:59 UTC
This problem was already addressed as part of bug #1198849. The patch that already solves this is: https://review.gluster.org/14933

So I'm closing this bug as CURRENTRELEASE.