Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#5169 closed Bug (fixed)

[PATCH] fix compilation error in torrent.c:1677:9: error: format not a string literal and no format arguments

Reported by: ALLurGroceries Owned by: jordan
Priority: Normal Milestone: 2.80
Component: libtransmission Version: 2.73
Severity: Normal Keywords:
Cc:

Description

Got this error compiling r13650 using gcc-4.7:

torrent.c: In function ‘torrentStart’:
torrent.c:1677:9: error: format not a string literal and no format arguments [-Werror=format-security]

Trivial patch attached.

Attachments (1)

fixformatstring.patch (489 bytes) - added by ALLurGroceries 9 years ago.

Download all attachments as: .zip

Change History (5)

Changed 9 years ago by ALLurGroceries

comment:1 Changed 9 years ago by x190

I suspect this may be intentional. Note that tr_torinf() in tr_torrentRecheckCompleteness() in torrent.c uses the same format. Apparently, the various GUIs can then choose to have this logged or not. Not sure how that is done though. Can someone please explain?

comment:2 follow-up: Changed 9 years ago by jordan

  • Milestone changed from None Set to 2.80
  • Status changed from new to assigned
  • Version changed from 2.73+ to 2.73

x190, I'm not sure I understand your question?

comment:3 Changed 9 years ago by jordan

  • Resolution set to fixed
  • Status changed from assigned to closed

Fixed in r13658.

comment:4 in reply to: ↑ 2 Changed 9 years ago by x190

Replying to jordan:

x190, I'm not sure I understand your question?

That's alright. I worked my way through it and was about to delete my comment:1. Anyway, I got you to do the commit. :-)

Not sure why you changed all those other ones? They already worked properly. If code consistency was the name of your game shouldn't you ditch those 'macro-like _()' thingies, if they don't have placeholders, or alternately use them everywhere?

  • In torrent.c:

Why use the '_()' format here unless you use it everywhere?

Line 1667:

tr_torinf( tor, "%s", _( "Restarted manually -- disabling its seed ratio" ) );

Line 1819:

tr_torinf( tor, "%s", _( "Removing torrent" ) );
  • Also, in torrent.c:

Line 2046:

tr_torinf( tor, _( "State changed from \"%1$s\" to \"%2$s\"" ),
                      getCompletionString( tor->completeness ),
                      getCompletionString( completeness ) );

While that does work, the _() format is not needed?

  • Just to mix it up a bit more, verify.c uses the following format:

tr_torinf( tor, "%s", _( "Queued for verification" ) );

  • In all your changes, using the "%s" placeholder seems redundant unless you also wish to use the '_()' format for the string.
Last edited 9 years ago by x190 (previous) (diff)
Note: See TracTickets for help on using tickets.