STM32 gotchas
288. Demo code may be flawed, even if it comes from reputable source

Example code is provided usually to showcase a certain feature, but its functioning may be subject to various circumstances - using a particular compiler with particular setting, using a particular hardware, etc. There even may be functional flaws which are not revealed unless inspected closely.

One example of a less-than-perfect example has been discussed here. Another such case is ST's older demo code for ethernet-capable chips, where the firmware after reset waits in a loop for a certain period to establish link, so if cable is connected after this period or a switch with long connection time is used, the demo fails to work.

There is no point in discussing legalities - such code is usually provided under extensive disclaimers, and at the end of the day, all the responsibility is upon the user.

The corollary here is, that users should make sure they understand any code which comes as an example, and make sure it truly fulfills all their requirements under all expected operating circumstances, especially if such code is to be modified and used as basis for a production code.