Bug 207478 - a lot gcc warnings because of %{public}s format specifier
Summary: a lot gcc warnings because of %{public}s format specifier
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Template Framework (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Víctor M. Jáquez L.
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-02-10 10:24 PST by Víctor M. Jáquez L.
Modified: 2021-04-27 21:21 PDT (History)
22 users (show)

See Also:


Attachments
Patch (43.41 KB, patch)
2020-02-10 10:40 PST, Víctor M. Jáquez L.
no flags Details | Formatted Diff | Diff
Patch (44.17 KB, patch)
2020-02-12 03:49 PST, Víctor M. Jáquez L.
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Víctor M. Jáquez L. 2020-02-10 10:24:08 PST
While compiling with GCC a lot of big warnings are shown because those macros boil down to vfprintf() in Linux, and that {public} specifier is invalid. It is only for os_log [1]


1. https://developer.apple.com/documentation/os/logging?language=objc
Comment 1 Víctor M. Jáquez L. 2020-02-10 10:40:08 PST
Created attachment 390262 [details]
Patch
Comment 2 Darin Adler 2020-02-11 13:01:20 PST
Comment on attachment 390262 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=390262&action=review

> Source/WTF/wtf/Assertions.h:487
> +#define LOGDSTR "s"

In WebKit coding style we normally prefer words over clumps of letters. I don’t know that LOGDSTR is a good choice for the project. Is this referring to something named "logd"? Maybe PUBLIC_LOG_STRING would be a good name? Also, why not put the "%" into the macro?
Comment 3 Keith Rollin 2020-02-11 13:31:04 PST
(In reply to Darin Adler from comment #2)
> Also, why not put the "%" into the macro?

I think that leaving the "%" out of the macro follows standard macros like PRId64.

Any naming convention should take into account other types of format specifications that might be used. For instance:

PUBLIC_LOG_STRING: {public}s
PRIVATE_LOG_STRING: {private}s
FUTUREOPTION_LOG_STRING: {future-option}s

PUBLIC_LOG_OBJCOBJECT: {public}@
PRIVATE_LOG_OBJCOBJECT: {private}@
FUTUREOPTION_LOG_OBJCOBJECT: {future-option}@

So while I like LOGDSTR for its brevity, it doesn't scale.
Comment 4 Darin Adler 2020-02-11 16:08:35 PST
(In reply to Keith Rollin from comment #3)
> (In reply to Darin Adler from comment #2)
> > Also, why not put the "%" into the macro?
> 
> I think that leaving the "%" out of the macro follows standard macros like
> PRId64.

It does. That alone doesn’t seem like reason to follow suit, though.
Comment 5 Keith Rollin 2020-02-11 19:05:19 PST
(In reply to Darin Adler from comment #4)
> (In reply to Keith Rollin from comment #3)
> > (In reply to Darin Adler from comment #2)
> > > Also, why not put the "%" into the macro?
> > 
> > I think that leaving the "%" out of the macro follows standard macros like
> > PRId64.
> 
> It does. That alone doesn’t seem like reason to follow suit, though.

What's the reason for not following suit?

Personally, I'd like to be consistent with the standard. That way I don't have to remember "OK, add the % for the standard macros, but leave it out for WebKit macros. Or is it the other way around...".
Comment 6 Víctor M. Jáquez L. 2020-02-12 02:25:45 PST
(In reply to Keith Rollin from comment #5)
> (In reply to Darin Adler from comment #4)
> > (In reply to Keith Rollin from comment #3)
> > > (In reply to Darin Adler from comment #2)
> > > > Also, why not put the "%" into the macro?
> > > 
> > > I think that leaving the "%" out of the macro follows standard macros like
> > > PRId64.
> > 
> > It does. That alone doesn’t seem like reason to follow suit, though.
> 
> What's the reason for not following suit?
> 
> Personally, I'd like to be consistent with the standard. That way I don't
> have to remember "OK, add the % for the standard macros, but leave it out
> for WebKit macros. Or is it the other way around...".

I do agree. It is better, IMO, to be consistent with other formatting macros.
Comment 7 Víctor M. Jáquez L. 2020-02-12 03:49:26 PST
Created attachment 390505 [details]
Patch
Comment 8 Víctor M. Jáquez L. 2020-02-12 03:51:58 PST
(In reply to Keith Rollin from comment #3)
> (In reply to Darin Adler from comment #2)
> > Also, why not put the "%" into the macro?
> 
> I think that leaving the "%" out of the macro follows standard macros like
> PRId64.
> 
> Any naming convention should take into account other types of format
> specifications that might be used. For instance:
> 
> PUBLIC_LOG_STRING: {public}s

Done. Now this symbol is used.

> PRIVATE_LOG_STRING: {private}s
> FUTUREOPTION_LOG_STRING: {future-option}s
> 
> PUBLIC_LOG_OBJCOBJECT: {public}@
> PRIVATE_LOG_OBJCOBJECT: {private}@
> FUTUREOPTION_LOG_OBJCOBJECT: {future-option}@
> 
> So while I like LOGDSTR for its brevity, it doesn't scale.
Comment 9 Darin Adler 2020-02-12 15:58:34 PST
(In reply to Keith Rollin from comment #5)
> What's the reason for not following suit?

To me PUBLIC_LOG_STRING doesn’t seem much like PRId64. I agree that if you thought of them as similar and closely related then we’d want them to match.

> Personally, I'd like to be consistent with the standard. That way I don't
> have to remember "OK, add the % for the standard macros, but leave it out
> for WebKit macros. Or is it the other way around...".

OK, tastes differ, and I certainly won’t insist.
Comment 10 Víctor M. Jáquez L. 2020-02-17 05:26:59 PST
May I have r+ & q+ ? 

O:)
Comment 11 WebKit Commit Bot 2020-02-17 10:48:04 PST
Comment on attachment 390505 [details]
Patch

Clearing flags on attachment: 390505

Committed r256745: <https://trac.webkit.org/changeset/256745>
Comment 12 WebKit Commit Bot 2020-02-17 10:48:06 PST
All reviewed patches have been landed.  Closing bug.
Comment 13 Radar WebKit Bug Importer 2020-02-17 10:49:14 PST
<rdar://problem/59517129>