45

In the project, I found a file, math.c, with a big GPL header and ...

//------------------------------------------------------------------------------
/// Returns the minimum value between two integers.
/// \param a  First integer to compare.
/// \param b  Second integer to compare.
//------------------------------------------------------------------------------
unsigned int min(unsigned int a, unsigned int b)
{
    if (a < b) {
        return a;
    }
    else {
        return b;
    }
}

OK, cool so I need to get min value and ... this file!? So I need to open the whole project because of it? Or do I need to reinvent mathematics?

I don't believe it's just insane, so the question is: when we can just remove the GPL header?

Must I be a weirdo and do it?:

unsigned int min(             unsigned int
JEIOfuihFHIYEFHyigHUEFGEGEJEIOFJOIGHE,
unsigned int hyrthrtRERG            ) {  if
(JEIOfuihFHIYEFHyigHUEFGEGEJEIOFJOIGHE
< hyrthrtRERG            ) {  return JEIOfuihFHIYEFHyigHUEFGEGEJEIOFJOIGHE;  }
else {return hyrthrtRERG            ;    } }

Seriously, do they want me to write code like the above?

Peter Mortensen
  • 1,050
  • 2
  • 12
  • 14
cnd
  • 1,874
  • 1
  • 14
  • 19
  • 23
    Well, in the recent case of Google vs Oracle `the jury did find that one nine-line function that Google acknowledged copying was infringing` (from [ArsTechnica](http://arstechnica.com/tech-policy/2012/05/jury-rules-google-violated-copyright-law-google-moves-for-mistrial/)). – Zenon May 12 '12 at 05:11
  • 5
    Aww come on, seriously, min? – Mircea Chirea May 12 '12 at 07:34
  • @MirceaChirea Yes I think I need to write max myself :( And I hope the code of "MY OWN VERSION OF MAX" will not be related to this GPL min – cnd May 12 '12 at 08:20
  • 2
    It is common practice to add license headers to each and every file of a project that falls under said license. Though we could argue about the need of *yet another* min function. – Mircea Chirea May 12 '12 at 08:44
  • so it's a part of example... my main part will be very different but I still need this math operations so ... need I ... steal them? :P or must I write my own ^^ like above in question... – cnd May 12 '12 at 08:49
  • 39
    I'd say the very existence of this question proves a bad thing - The job of a programmer has become less programming, more legal clutter and bureaucracy – K.Steff May 12 '12 at 14:53
  • 5
    **Copy it**. A trivial function like `min` is not covered by copyright. See my answer for details. – Tony the Pony May 12 '12 at 15:59
  • 6
    @Loki, you're missing it by a mile. Algorithms are covered by patents, not by copyright. Copyright expires 70 years after the death of the author, so works copyrighted in the 60's are still quite fresh. Finally, the question is about copying THIS code, not about the algorithm. – alexis May 12 '12 at 22:22
  • Write the test cases, then uses your past experiences to help you make the test pass. Remember you have “The freedom to study how the program works”, but not the freedom to rip it off. – ctrl-alt-delor May 14 '12 at 12:42
  • 2
    I call dibs on `return a < b ? a : b;` so don't even think of doing that without my permission! **Update:** Doh! Alexios and GordonM beat me to it. Glad to see that they're liberal in their licensing. – Caleb May 18 '12 at 14:58

14 Answers14

56

Unlike many of the user here, I would simply suggest: Copy it!

Make sure the formatting of the code fits your coding standard and also you should probably remove or rewrite the comment. No one will ever know you copied it - when a piece of code is this simple, you might as well have written it from scratch. If your coding standard somehow requires the function to look exactly as it does in the snippet, so be it - as long as it looks as it would look if you had written it from scratch.

Think about it, this is hardly(!) the first time this exact piece has been written - when something is this trivial, there is little reason not to copy it, if you do not feel like writing it yourself.

Even having this discussion seems a little superfluous to me - we need to be pragmatic if we are to get any real work done!

nilu
  • 1,024
  • 7
  • 12
  • 6
    the real questions is where is the barrier between trivial and non-trivial and is there way to be absolutely sure that people will not point my code with something alike "LOOK IT'S MY GPL MIN REALIZATION!"... I really afraid those people >_ – cnd May 12 '12 at 08:24
  • I understand your concern and I guess that there are no true guidelines that answer this question. I would ask myself: Does the code look like you could have written it yourself? Have other people written similar code before? If yes, you should be on the safe side I would think. – nilu May 12 '12 at 08:28
  • 23
    Well, there is the concept of *threshold of originality* in copyright. And such a simple method should hardly be copyrightable. IANAL, though, and jurisdictions vary. Still, something that every CS undergrad has written at least five times in quite exactly the same manner might very well fall under this. – Joey May 12 '12 at 08:30
  • I've changed some of formatting in question, I hope it's safe now... sadly I liked GPL version more :'( – cnd May 12 '12 at 08:36
  • If the new version fits your coding standards, I wouldn't like to see the rest of your code ;) - use GPL version if it fits your coding standards. – nilu May 12 '12 at 08:48
  • no... I mix K&R with GNU for personal standard ;) – cnd May 12 '12 at 08:54
  • "when something is this trivial, there is little reason not to copy it, if you do not feel like writing it yourself." Oh wow, I didn't know that you could break the law if it was something small and unimportant. That's great news! I think I'm going to steal some sweets, seeing as they're only worth a few cents. – Mark Byers May 12 '12 at 19:15
  • #Mark Byers: Let's say there are a limited number of reasonable ways to implement a MIN function. If one had enormous amounts of time, one could look through all the code in the world, filtering out any variation of MIN that was found. Would any reasonable version of min be left? Hardly. Let us then say that the programmer wrote his own version of MIN and it ended up looking exactly like the one from math.c - would it then be okay? What difference would it then make if he had just copied it? The end result would be EXACTLY the same. I am no legal expert, but I hope you see my point? – nilu May 12 '12 at 23:15
  • 1
    @nilu, the point is not to implement a _different_ version of `min`, but to implement one without relying on code that he has no right to use. It is trivial to write it from scratch, and it's the right thing to do. I agree that it would be hard to get caught for copying and pasting something so simple, but that doesn't make it right. – alexis May 13 '12 at 10:15
  • 5
    @nilu: `Let us then say that the programmer wrote his own version of MIN and it ended up looking exactly like the one from math.c - would it then be okay?` Yes, if it was an accident. "What difference would it then make if he had just copied it?" Bits have *color*. http://ansuz.sooke.bc.ca/entry/23 This is not something most computer scientists can understand - it is indeed a complex topic, but it is something that is recognized by law. If you are in doubt about whether something is legal or not, you had best to **talk to a lawyer**. – Mark Byers May 13 '12 at 16:37
  • 4
    @alexis: I understand your point, but I do not really agree - if the resulting code is identical, no one but the programmer can know if it was copied or written from scratch. Obviously, one should have little trouble implementing min and it would probably take less time than finding another implementation. However, if a programmer does indeed copy it and no else knows that he has not written the function himself, what damage has then been done? Unless the programmer is feeling some kind of 'guilt', the answer is none. The rest is simply semantics. – nilu May 13 '12 at 17:43
  • 1
    @MarkByers: If no one can prove (let us imagine this scenario) where the 'bits' came from, how can the law then differentiate between copied/not copied? It can't. If one was to consult a lawyer every time he wrote (or copied) a little bit of code, no one would get anything done. – nilu May 13 '12 at 17:51
  • @nilu: If no-one can prove that I stole some sweets (let's just imagine that in this scenario) then what's the point of a law saying you can't steal things? – Mark Byers May 13 '12 at 17:57
  • I'm with @Mark. There's the question of what is the practical and ethical thing to do, and then there's the question of how to avoid getting in trouble--with or without cause. If a task is so obvious that you might match someone else's code by accident, this very fact will protect you, guilty or innocent. Those google folks obviously went well beyond what could have happened by accident, or else google's lawyers really botched it. – alexis May 13 '12 at 18:32
  • 1
    Really it's very simple unless you DO copy code you don't have the rights to. If you write your own code, you don't need to worry about the license to someone else's. (Software patents are a whole other story, of course). – alexis May 13 '12 at 18:32
  • 6
    @MarkByers: When I say 'cannot prove', I mean that no physical evidence exist to show that a crime _has even been_ committed - the crime which has been commited is completely confined to the mind of the programmer. Obviously, this cannot be the case if some sweets are stolen - this has a physical impact on the world (lollipop -= 1). If the 'crime' is confined to your own mind, whos to judge whether it is moral or immoral? – nilu May 13 '12 at 21:31
  • 1
    @nilu now that you put it that way, it makes sense: "Copy it, it's a minor infraction and you're not going to get caught". I won't argue with that--it's a minor thing indeed. But don't confuse things again by implying that it is *not* an infraction, that's a whole different argument and you can't win it. – alexis May 14 '12 at 21:08
  • 6
    **Lawyers made us afraid of doing simplest most natural things.** – Kamil Szot May 18 '12 at 00:39
  • 2
    +1 I am just thinking of the rules for plagiarism from college. One of the rules is, you don't have to cite common knowledge. – Jonathan Henson May 18 '12 at 01:25
  • Oracle vs. Google anyone? http://www.slashgear.com/oracle-android-argument-flounders-thanks-to-coder-judge-16228583/ – dukeofgaming May 18 '12 at 04:28
  • 1
    Hopefully if you did get sued it would be for reasonable damages. I mean, how much damage can copying an obvious 4 line function really cause? I wouldn't expect the damages to be more then a few million dollars. – Buttons840 Jul 17 '12 at 17:54
20

Disclaimer: I am not an attorney. Use my advice at your own risk.

This implementation of min is not copyrightable, since there are only very few reasonable ways of writing it.

In the legal world, this is known as the merger doctrine (also known as the idea-expression divide). The (non-copyrightable) idea of the function is said to have "merged" with the (potentially copyrightable) expression. Therefore, the code is not subject to copyright -- you are free to use it.

To be on the safe side, don't copy it verbatim. Use different names for variables, apply your own formatting, don't copy comments word for word. The exact literal representation of this code may be covered by copyright.

Keep in mind that this doesn't guarantee someone won't sue you, but at least you will have a strong defense.

Also, bear in mind that even if a piece of code isn't protected by copyright, it might still be covered by a software patent (This is not the case for your min function).

Tony the Pony
  • 440
  • 1
  • 3
  • 10
18

It doesn't directly answer your question, but try this:

#define min(a,b) ((a) < (b) ? (a) : (b))

I hereby release this glorious, complex macro to the public domain. Though I may have to publish a paper on this technique.

If you're macro-phobic, try this inline version (really, unless you're coding on a SPARC, you'll save lots of CPU cycles by not wrapping a function as ubiquitous as min in enter/exit code):

inline int min(int a, int b)
{
    return a < b ? a : b;
}

The issue of code licensing for trivial snippets is a bit of a nuisance, really. Check with a lawyer, but I'm tempted to assume that they can't really be licensed and/or the licensing can't be enforced in practice. Same as you can't copyright or trademark the word ‘word’, then lean on people who use it. (oops)

Alexios
  • 349
  • 1
  • 6
  • 1
    Oh, they can certainly copyright that code, but given the simplicity of the algorithm, they'd be hard pressed to prove in court that you copied it unless you did something stupid like left comments intact, etc. The rule is not that you can't use the same code, the rule is that you can only do so if you wrote it using your own brain, and did not copy the original in any fashion. – Gort the Robot May 12 '12 at 04:57
  • 1
    it's not about brain at all... it's weird part of licensing. – cnd May 12 '12 at 05:04
  • 3
    @StevenBurnap Of course the original code would also have the same problems: can they prove they have copyright (ie. that they didn't copy it from some earlier implementation)? – Richard May 12 '12 at 08:26
  • by the way I think that functions definition in #define (when that is not one operator) is wrong manner / way of code in C. – cnd May 12 '12 at 08:39
  • 19
    Problem with macro version of min comes when you try to do `min(a++,b++)`. –  May 12 '12 at 08:45
  • That's very true — my habit of min as a macro comes from my distant past for reasons I'd rather not go through (maintaining existing code with, erm, weird requirements). It got me into the habit of never using `++` or `--` in there, so it's never been a problem for me. – Alexios May 12 '12 at 10:11
  • 6
    "release this...to the public domain" is very US-centric. It doesn't mean the same thing in many countries and indeed in some is not legally possible. –  May 12 '12 at 11:46
  • @GrahamLee: that's very interesting (I'm on the non-US side of the Duck Pond, by the way). Do you have any links I could have a look at? Not that it's actually that important in the context of this question. – Alexios May 12 '12 at 14:01
  • 9
    Thanks, but on a compiler from the 2000s, a compiler can inline trivialities like `min`. – DeadMG May 12 '12 at 14:34
  • @Alexios the discussion here is a good indication that the problem exists: http://en.wikipedia.org/wiki/Wikipedia:Granting_work_into_the_public_domain –  May 12 '12 at 14:43
  • @Alexios: Germany apparently does not accept the concept of public domain (http://programmers.stackexchange.com/a/147120/12917) – Martin York May 12 '12 at 17:13
  • unless of course somebody has a patent on finding the minimum of two values, and another patent on using a macro to avoid a return code, and a patent on using 'min' in a particular business role – Martin Beckett May 13 '12 at 15:44
  • @Alexios. [WTFPL](http://sam.zoy.org/wtfpl/) has some comments about the public domain. – TRiG May 14 '12 at 11:47
13

It's an absurd situation, I agree, but you have only yourself to blame. If you are writing proprietary code, you should not be reading GPL-licensed source files, period. Remove math.c from your filesystem, keep the documentation, and feel free to re-implement any part of the API that you need. If you don't read the code, you don't need to worry if your own code turns out similar.

Wasteful, you say? The GPL intentionally prevents you from benefiting from free code without giving back to the ecosystem. If you can't or won't meet its terms, and you don't want to implement yet another math library, you can always buy one or find a free one that comes with a license you can accept.

Microsoft's programmers are not allowed to read open source code, to protect the company from legal problems. For purely ethical reasons, you should do the same with any program whose license you don't intend to adhere to.

You don't have a right to use this math.c, but nobody is trying to corner the market on implementations of min. The goal of the GPL is to increase programmer "freedom" (and the end user's freedom), not to restrict it. The GNU license, the FSF, and the Free Software Movement started with Richard Stallman, and Stallman started with re-implementing from scratch each new version of Symbolics lisp as it came out. The FSF would not (and could not) go after anyone for re-implementing a GPL library.

alexis
  • 667
  • 3
  • 7
  • So but, it's really strange example. It's example, that means I must to read it and follow it... but as far as I understand I'm free to not pick GPL license here. So I know who is Stallman ;) – cnd May 12 '12 at 11:50
  • 2
    Sholy, sorry but I've no idea what you're saying! What example? (Are you also asking me who Stallman is? Google it. Or just check wikipedia.) – alexis May 12 '12 at 12:06
  • 3
    "Microsoft's programmers are not allowed to read open source code" oh my, that's horrible - is there anywhere i can read about that? Google isn't helping. – amara May 12 '12 at 12:52
  • Good question. I read about it in some Iron Python development forum, but unfortunately I cannot find it now. Summary: Jim Hugunin (http://hugunin.net/microsoft_farewell.html) mentioned that they aren't allowed to look at the python implementation and someone jokingly asked if they're allowed to look at their own code (Microsoft had made Iron Python open source). The answer is: They made a special exception for Iron Python. – alexis May 12 '12 at 13:15
  • The people whose freedom the GPL is intended to increase are all the users of the program, not (specifically) programmers. – James Youngman May 12 '12 at 22:29
12

I'm releasing the following code under the BSD license. As that license is a lot more permissive you shouldn't run into copyright issues if you use my implementation.

unsigned int min(unsigned int a, unsigned int b)
{
    return (a > b? b: a);
}
GordonM
  • 6,295
  • 1
  • 21
  • 30
  • 1
    How can I be sure that you not sealed that GPL code and rewrite it ? :P (just joking) – cnd May 12 '12 at 08:26
  • 1
    You're not. But if you used my code you can claim you used it in good faith. – GordonM May 12 '12 at 08:27
  • Also, it's obvious that my code isn't a copy because it uses a greater than instead of a less than! – GordonM May 12 '12 at 08:40
  • 4
    Rejoice, brethren, as the new age has dawned - we can now find `min` in closed-source software. Also, @Sholy, now it's GordonM's problem whether he has copied it, or not. – K.Steff May 12 '12 at 14:43
  • Thanks for your generosity, but there's nothing to be licensed. Trivial code like `min` is not subject to copyright -- see my answer for detailed explanation. – Tony the Pony May 12 '12 at 15:54
  • 7
    You are also releasing it under "Creative commons" See the bottom of this page about code pasted here. – Martin York May 12 '12 at 17:15
  • 1
    See: http://meta.programmers.stackexchange.com/q/3585/12917 – Martin York May 12 '12 at 21:13
  • I think min and max are defined for the case where a=b. It is so tightly defined that the code is a translation. – ctrl-alt-delor May 14 '12 at 12:46
7

Answer: Only with explicit permission of the author.

That's copyrighted code. You cannot copy it without permission of the author.

You will have to write your own version of min, or copy a variant of min that uses a different license.

Remember, with copyright, it's the code that is protected, not the algorithm. Copyright law comes from text. Even if "math.c" was nothing but comments and had no executable code at all, it'd still be protected under copyright.

Gort the Robot
  • 14,733
  • 4
  • 51
  • 60
  • 1
    What means own version? MY OWN version of MIN, sounds hilarious! – cnd May 12 '12 at 04:58
  • 2
    Remember, you don't own `min`, you own a particular sequence of characters that happens to implement `min`. – Gort the Robot May 12 '12 at 05:00
  • 1
    So how much I must to change it to make it "MY OWN VERSION OF MIN" sorry, but it's funny. – cnd May 12 '12 at 05:02
  • 2
    You cannot change it at all without permission of the author except for personal use. You have to rewrite it from scratch. That's the whole point. Note that if you sat down at a blank editor and wrote something nearly identical to that, it'd be fine, because you didn't copy it. (Assuming you weren't typing from memory.) – Gort the Robot May 12 '12 at 05:04
  • Are you joking!? Why I must to write the same when I already got it... it's just pointless. No one except me will know the file history. What if I write the same, it's not that hard. – cnd May 12 '12 at 05:07
  • 2
    No, I am not joking. And yes, you can probably get away with it in cases like this. It'd be up to the copyright holder to prove that you'd done it. Note that I am just telling you what the law is, not defending it. – Gort the Robot May 12 '12 at 05:10
  • So ... I rename math.c to non_gpl_math.c and clean header. How is it possible to detect that it was gpl math.c ... I think it's ENOUGH changes for "OWN VERSION OF MIN" – cnd May 12 '12 at 05:14
  • Again, that's breaking copyright. Anything you do based on copyrighted work has to abide be the original license. The amount of change does not matter. The only way for it to be your own version of `min` is for you to start with a blank editor and write it from scratch. – Gort the Robot May 12 '12 at 05:30
  • So I can write it from scratch, the question is where is guaranties that someone will not say me "Hey! it's my GPL Hello World" – cnd May 12 '12 at 05:48
  • Nothing. But they'd have to prove it in court. – Gort the Robot May 12 '12 at 05:49
  • then why I need to act like that? re code trivial things if they will still need to prove it in court, I think the changes is matters and there is nothing about file history. – cnd May 12 '12 at 05:52
  • 3
    Because if you don't recode these trivial things, you're using someone else's work in a way that they haven't given you permission to do. If it's so trivial that you don't need it, don't use it. – alexis May 12 '12 at 11:47
  • 1
    -1 You are right, in general, but this is a special case -- see my answer. – Tony the Pony May 12 '12 at 15:53
  • It's a completely artificial case, really as this version of `min` is taken from the GNU compiler and is their implementation of the standard C++ runtime `min` function. No one should need to write this themselves unless they are writing their own C++ compiler. The amusing bit is that my own company had to rewrite some bits of this for fairly arcane legal reasons due to static linking to non-GPLed code. – Gort the Robot May 12 '12 at 16:47
  • @StevenBurnap Have you heard of "access and similarity"? Whether he _in fact_ sat down at a blank editor doesn't legally matter, only that he _could have_ written it based on the other implementation. – Random832 May 12 '12 at 20:17
7

This is what Google Supposedly ripped off. This seems like common sense for an array.

 908     /**
 909      * Checks that fromIndex and toIndex are in range, and throws an
 910      * appropriate exception if they aren't.
 911      *
 912      * @param arrayLen the length of the array
 913      * @param fromIndex the index of the first element of the range
 914      * @param toIndex the index after the last element of the range
 915      * @throws IllegalArgumentException if fromIndex > toIndex
 916      * @throws ArrayIndexOutOfBoundsException if fromIndex < 0
 917      *         or toIndex > arrayLen
 918      */
 919     private static void rangeCheck(int arrayLen, int fromIndex, int toIndex) {
 920         if (fromIndex > toIndex)
 921             throw new IllegalArgumentException("fromIndex(" + fromIndex +
 922                        ") > toIndex(" + toIndex+")");
 923         if (fromIndex < 0)
 924             throw new ArrayIndexOutOfBoundsException(fromIndex);
 925         if (toIndex > arrayLen)
 926             throw new ArrayIndexOutOfBoundsException(toIndex);
 927     }
Chrispix
  • 171
  • 1
  • If this is all, the verdict will be tossed on appeal. But according to Wired, the judge also found Google copied 8 other files. See http://www.wired.com/wiredenterprise/2012/05/google-oracle-decompile/ – Tony the Pony May 12 '12 at 16:49
  • 5
    Yes, but "common sense" isn't the bar for copyright. It's whether they copied and edited or wrote themselves from scratch. Whether something is "Common sense" is the test for patents, not copyrights. In other words, Oracle can copyright that text, but they can't patent that algorithm. – Gort the Robot May 12 '12 at 16:49
  • These 9 lines are a classic example of the merger doctrine. How many other ways are there to perform a range check on an array? – Tony the Pony May 12 '12 at 16:52
  • 1
    @TonythePony, lots, if the function throws an exception containing a textual message. – avakar May 12 '12 at 16:58
  • @avakar But there aren't many ways to phrase that message – Tony the Pony May 12 '12 at 17:01
  • Note that the comment block is also protected under copyright. There are a huge number of ways to express that. Copyright protects the text, not the algorithm. – Gort the Robot May 12 '12 at 22:59
  • 1
    The comment block is only protected if it reaches a minimum threshold of originality. A short, descriptive phrase is not protected. – Tony the Pony May 13 '12 at 08:31
  • 6
    Few people have mentioned that the person who copied this text at Google is *also the person who wrote it* at Sun. Programmers have to realize that Stallman--the crazy bearded extremist--was *right*. Money, that root of all evil, makes people forget why they participate in technology in the first place. :-/ – HostileFork says dont trust SE May 18 '12 at 00:44
5

I won't use this code anyway, because the comment doesn't match with what the code does. The comment talks about integer, while the code uses unsigned int. Who knows what errors are buried within the depths of this function?

Seriously, this is where "Don't reinvent the wheel" becomes ridiculous and you forgot to take it with a grain of salt. Just write your own version from scratch, match it with the naming convention and style guide of your code (e.g. math_min_uint(x, y)), make sure it works (unit test or whatever) and go on with life and without copyright issues.

With growing experience, these trivial snippets you need again and again are just in your toolbox and you will rewrite them without thinking too much, or simply get them from your own library.

Secure
  • 1,918
  • 12
  • 10
2

People seem to be forgetting that copyright law, both in spirit and letter, means that the act of actually copying is prohibited - not the act of expressing the same thought yourself, not even if the result turns out suspiciously similar.

If you take the GPL'd code, modify it, use it in a way that is against the license under which you received it, and claim it is not a derived work, then you are breaking the law. Even if you use your second version - you have changed the names of all variables, and altered the formatting, but it's still derived from the original.

If, however, you write your own version of min, and due to the triviality of the task, the fact that there are only so many ways you can sensibly write such a thing, and a bit of coincidence, your version ends up being exactly identical to the GPL'd code, then you haven't copied anything.

Whether or not either story would pass in court is a different matter though. If a larger or more complex code sample shows up somewhere else, complete with comments, formatting, and spelling errors, you'll have a hard time convincing anyone that you wrote it independently, more so if it can be shown that you knew the original source (which, given the fact that you have posted it here, should be fairly trivial).

tdammers
  • 52,406
  • 14
  • 106
  • 154
1

If the code is really is trivial as the "min" example then there is a very high probability that someone else has already implemented the same functionality under a different open source license.

Depending on the license you may verywell be allowed to include the code in your closed source appliantion.

Niels Basjes
  • 119
  • 4
1

Just write it yourself in 30 seconds. You can use exactly the same algorithm. Just don't copy/paste.

Copyright only protects the expression of an idea, not the idea itself. You can use the idea directly providing you don't copy it.

FWIW, I doubt that copying such a trivial piece of code would get you into trouble anyway. Damages would be zero, and it would probably fall under fair use in most jurisdictions. But legal cases are such a pain that I wouldn't want to risk it.

mikera
  • 20,617
  • 5
  • 75
  • 80
1

As its GPL code the big question here is are you planning distrubute your code or sell your software.

If you are just using it internally the GPL gives you complete freedom to do as you wish.

If you are planning to distribute you package -- the easiest thing is to GPL your package on the same terms as any GPL source you used. There are other ways but it gets complicated.

If you are planning to sell your software, you must distribute the source code for any GPL code you used and/or amended under the same GPL license by which you obtained it.

James Anderson
  • 18,049
  • 1
  • 42
  • 72
0

If you're using C++ and not C, sidestep this issue by using the standard library std::min or std::max in <algorithm>:

http://www.cplusplus.com/reference/algorithm/min/

That buys you generality, and it will work for any comparable type. Also: when whatever d-bag tries to claim they invented it and is covered by software patents, they'll be rumbling with the ISO committee...not you.

In the general case, take note of who published the code. Corporation, or sane individual? If it's a sane individual (as is the case with much open source), write a nice note to them and get permission. Save their response saying it's okay. Problem solved.

-2

For the general case: More complex code that is definitely copyright-able, as opposed to min and max (that may or may not be copyright-able).

Then License your code in compliance with the library i.e. GPL! Note however that there are LGPL libraries (and GPL with exceptions) that let you use their implementations while giving your code whatever licence you wish.

ctrl-alt-delor
  • 570
  • 4
  • 9