pappl icon indicating copy to clipboard operation
pappl copied to clipboard

papplDeviceParseID() should return a size_t to better work with cupsGetOption()

Open wifiprintguy opened this issue 1 year ago • 1 comments

Describe the bug The papplDeviceParseID() function has the following signature / prototype:

int papplDeviceParseID(const char *device_id, cups_option_t **pairs);

It is expected that "pairs" is then used with cupsGetOption(). That has the following signature:

extern const char *cupsGetOption(const char *name, size_t num_options, cups_option_t *options) _CUPS_PUBLIC;

Notice that the return value of papplDeviceParseID() is supposed to be provided to cupsGetOption() as the "num_options" parameter, which is defined as a size_t. Casting works but should be unnecessary.

Change papplDeviceParseID() to return a size_t.

wifiprintguy avatar Oct 07 '22 05:10 wifiprintguy

Actually, current CUPS 2.x uses the int type for the option count. size_t is being introduced for CUPS 3.x.

Deferring this request to a future PAPPL 2.0 release where we can a) require CUPS 3.x and b) break binary compatibility with prior PAPPL releases.

michaelrsweet avatar Oct 07 '22 11:10 michaelrsweet