Project

General

Profile

Actions

Bug #2910

closed

Rethinking __printflike in the context of drm's __printf

Added by davshao almost 8 years ago. Updated almost 8 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Start date:
05/05/2016
Due date:
% Done:

0%

Estimated time:

Description

Currently DragonFly drm defines printf to be __printflike. It seems likely to me that Linux drm actually expects behavior __printf0like, without the __nonnull(fmtarg) attribute.

For example, more recent versions of Linux drm want to define a function like this:

extern __printf(6, 7)
int drm_crtc_init_with_planes(struct drm_device *dev,
struct drm_crtc *crtc,
struct drm_plane *primary,
struct drm_plane *cursor,
const struct drm_crtc_funcs *funcs,
const char *name, ...);

and call it sometimes (well strangely enough, so far all of the time) with name == NULL.
Then inside the newer versions of the function is something like this:

if (name) {
__va_list ap;
__va_start(ap, name);
crtc->name = kvasprintf(GFP_KERNEL, name, ap);
__va_end(ap);
} else {
crtc->name = kasprintf(GFP_KERNEL, "crtc-%d",
drm_num_crtcs(dev));
}

The obvious fix is in sys/dev/drm/include/linux/compiler.h
to redefine __printf as __printf0like.

For curiosity's sake, given the gcc 4+ series of compilers now used for DragonFly in 2015
as opposed to 2004 when the __printflike and __printf0like distinction was made, is it
still necessary to have both __printflike and printf0like?

Actions #1

Updated by swildner almost 8 years ago

If Linux understands __printf as NULL being allowed for the format, defining __printf as __printf0like instead sounds reasonable. I'll leave that to whoever brings in such code in the future.

Regarding the second question about having both printflike and __printf0like, I'm not sure I understand. As long as __printflike implies __nonnull, we need an extra macro for cases where a NULL format shall be allowed. If we removed __nonnull from __printflike, we'd have to add __nonnull to all prototypes that have __printflike right now, in order to not lose these checks.

Actions #2

Updated by swildner almost 8 years ago

  • Status changed from New to Closed

Closing this issue.

Whoever brings in Linux code that may pass NULL to a function which itself is decorated with __printf, could change the macro to __printf0like().

Actions

Also available in: Atom PDF