On Thu, May 2, 2024 at 10:18 PM Marek Behún <kabel@xxxxxxxxxx> wrote: > On Thu, May 02, 2024 at 09:47:25PM +0300, Andy Shevchenko wrote: > > On Thu, May 2, 2024 at 9:40 PM Marek Behún <kabel@xxxxxxxxxx> wrote: > > > On Tue, Apr 30, 2024 at 06:17:45PM +0300, Andy Shevchenko wrote: > > > > On Tue, Apr 30, 2024 at 04:05:07PM +0200, Marek Behún wrote: > > > > > On Tue, 30 Apr 2024 15:53:51 +0300 > > > > > Andy Shevchenko <andy.shevchenko@xxxxxxxxx> wrote: > > > > > > On Tue, Apr 30, 2024 at 2:51 PM Marek Behún <kabel@xxxxxxxxxx> wrote: ... > > > > > > > +static int omnia_get_version_hash(struct omnia_mcu *mcu, bool bootloader, > > > > > > > + u8 version[static OMNIA_FW_VERSION_HEX_LEN]) > > > > > > > > > > > > Interesting format of the last parameter. Does it make any difference > > > > > > to the compiler if you use u8 *version? > > > > > > > > > > The compiler will warn if an array with not enough space is passed as > > > > > argument. > > > > > > > > Really? > > > > > > Indeed: > > > > > > extern void a(char *x); > > > > > > static void b(char x[static 10]) { > > > a(x); > > > } > > > > > > void c(void) { > > > char x[5] = "abcd"; > > > > > b(x); > > > > It's not the example I was talking about. Here should be a(x). > > Somehow I got lost. Let's return to my function, where I have > int omnia_get_version_hash(..., u8 version[static 40]); > > and then I use this function: > > u8 version[40]; > omnia_get_version_hash(..., version); > > If somehow I made a mistake and declared the version array shorter: > u8 version[20]; > omnia_get_version_hash(..., version); > I would get a warning. Yes. Would you get the same warning if you replace the parameter to a pointer? > So the purpose is to get warned if the compiler can prove that there is > not enough space in the destination buffer. -- With Best Regards, Andy Shevchenko