Re: [PATCH spice-streaming-server 1/3] Use defer style destruction instead of old C style and goto

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

 



On Thu, Nov 09, 2017 at 04:48:37PM +0100, Christophe de Dinechin wrote:
> > 
> > I consider a downside, if I have for instance 2 C open calls and want
> > to define 2 defers I cannot.
> 
> You can. You just need to put a surrounding block to make the lifetime of
> each of your cleanups more explicit.
> 
> My argument is really whether this is not dangerous. I think it could be
> encouraging bad code like:
> 
> fd = open(…)
> defer { close(fd); };
> close(fd);
> 
> // Copy-paste from the above, with variations
> fd = open(…)
> defer { close(fd); }
> kaboom();
> close(fd);
> 

You should not reuse the same variable twice in the same block for
different purpose, this is bound to cause this kind of bugs ;)

> This code is bad as in: it is broken on the infrequently taken exception path.
> Now we have two defer objects, and if something bad happens in kaboom(),
> we end up closing fd twice.
> 
> See the issue with multiple defer in a single block and why I’d rather avoid it?
> 
> > 
> > But back to the license "issue" (I don't see it considering the license)
> > somebody could consider your suggestion inspired by the previous ones
> > so subject to OpenStack licensing too.
> 
> There is no such thing as a license on ideas. And as I pointed out, that
> specific idea did not even originate where you found it. Being “inspired by”
> does not make code derivative. Linux is a prime example, being very
> strongly inspired by Unix down to system call names, but not derived from it.

There's a difference between being inspired by an idea (ie someone
described something in words to you, and you implemented it), and seeing
the actual C++ code, and reimplementing it saying you were only inspired
by it. In the latter case, you make it much easier for someone to
claim your code is mostly theirs copied and pasted.

Christophe

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]