Re: [libgpiod]: feature request: API functions, const correctness

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Aug 2, 2023 at 4:06 PM Hollerer Franz, Schrack Seconet AG,
Entwicklung <f.hollerer@xxxxxxxxxxxxxxxxxxx> wrote:
>
> Dear libgpiod-team,
>
> I have a request, and it would be great if you could consider it for future versions of libgpiod. Within the current API it is not obvious which function parameters are input-only parameters, and which parameter are output parameters, i.e., will be modified.
>
> I think it would be helpful if the API is const correct. As example, I think
>
> > struct gpiod_line_info *gpiod_chip_get_line_info(struct gpiod_chip *chip,
> >                                                unsigned int offset);
>
> should be changed to
>
> > struct gpiod_line_info *gpiod_chip_get_line_info(const struct gpiod_chip *chip,
> >                                                unsigned int offset);
>
> making it clear that the chip object is an input parameter which is not changed by the API function. Same argument applies for many other API functions...
>
> Thanks for consideration & Best regards,
>
> Franz Hollerer
>

Hi Franz!

No, this is not something I'm considering. The objects in the library
are all opaque. What the library does with them internally is none of
the user's business. It may want to modify the structs for some
internal tracking for all you know.

Doxygen docs in the headers are pretty clear on what argument is used
for what IMO.

Bartosz




[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux