Re: [libgpiod] gpiod_line_get_value_bulk may be broken?

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

 



On Thu, 10 Aug 2023 at 01:46, Kent Gibson <warthog618@xxxxxxxxx> wrote:

> Check the sizes of the memory you are allocating.
> e.g. this:
>
>             arr[c].chip = (struct gpiod_chip *)rtapi_kmalloc(sizeof(arr[c].chip), RTAPI_GFP_KERNEL);
>
> allocates the space for a pointer to a struct, not the struct itself.

Oh, that's embarrassing.

>             arr[c].chip = (struct gpiod_chip *)rtapi_kmalloc(sizeof(*arr[c].chip), RTAPI_GFP_KERNEL);

But that doesn't actually work:

"hal/drivers/hal_gpio.c: In function ‘build_chips_collection’:
hal/drivers/hal_gpio.c:119:41: error: dereferencing pointer to
incomplete type ‘struct gpiod_chip’
      arr[c].chip = rtapi_kmalloc(sizeof(*arr[c].chip), RTAPI_GFP_KERNEL);
"

The exact same structure compiles without error for the
gpiod_line_bulk a few lines lower. I think that the difference is that
gpiod.h includes the definition of struct gpiod_line_bulk, but only
the prototype of struct gpiod_chip.
(This is mainly based on googling Stack Overflow, so might be wrong)

> There is no code movement at all, this is just telling the linker to
> link libgpiod.a directly into your executable, rather than dynamically
> linking against libgpiod.so.
>
> The specifics of how to do that depend on your build.

But surely the compiler and linker need either the V2 code, or the
library object? How does it access these if we don't have them in our
repository?
Even if we add it as a build-time dependency, it isn't currently
available in the usual places?
I must be missing something? Or are you assuming that I am the only
one compiling LinuxCNC?

-- 
atp
"A motorcycle is a bicycle with a pandemonium attachment and is
designed for the especial use of mechanical geniuses, daredevils and
lunatics."
— George Fitch, Atlanta Constitution Newspaper, 1912




[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