Re: [PATCH v1 3/7] resource: Introduce resource_union() for overlapping resources

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

 



On Fri, Aug 14, 2020 at 5:37 PM Andy Shevchenko
<andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:
>
> On Fri, Aug 14, 2020 at 05:23:07PM +0200, Rafael J. Wysocki wrote:
> > On Thu, Aug 13, 2020 at 7:57 PM Andy Shevchenko
> > <andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:
> > >
> > > Some already present users may utilize resource_union() helper.
> > > Provide it for them and for wider use in the future.
> > >
> > > Deliberately avoid min()/max() macro as they are still parts of
> > > kernel.h which is quite a burden to be included here in order
> > > to avoid circular dependencies.
>
> ...
>
> > > +       if (!resource_overlaps(r1, r2))
> > > +               return false;
> >
> > I tend to add empty lines after return statements like this to make
> > them more clearly visible.
>
> Okay!
>
> > > +       r->start = r2->start < r1->start ? r2->start : r1->start;
> > > +       r->end = r2->end > r1->end ? r2->end : r1->end;
> >
> > Well, what about using min() and max() here?
>
> I devoted one paragraph in the commit message to answer this. The kernel.h
> (which I'm planning to split at some point) is a monster which brings more pain
> than solves here. Note, this is a header file and it's quite clean from
> dependencies perspective.

But this is code duplication (even if really small) and it is not
entirely clean too.

Maybe move the definitions of min() and max() to a separate header file?



[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux