Warn on unused return values in guidance code, resolves #2686.

https://github.com/Project-OSRM/osrm-backend/pull/2685/files

fixes an issue where we did

    elongate(fstStep, sndStep);

instead of

    newStep = elongate(fstStep, sndStep);

we didn't get any warnings.

The only way to trigger a warning here is to use

```cpp
__attribute__((warn_unused_result))
```

This changeset does exactly that: for the new guidance code prone to
these kind of issue we add such an attribute to the declaration.
This commit is contained in:
Daniel J. Hofmann
2016-08-02 15:43:29 +02:00
parent 583aaff286
commit 7f71f0ed12
13 changed files with 64 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
#ifndef OSRM_ATTRIBUTES_HPP_
#define OSRM_ATTRIBUTES_HPP_
// OSRM_ATTR_WARN_UNUSED - caller has to use function's return value
// https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html
#if defined(__GNUC__) && (__GNUC__ >= 4)
#define OSRM_ATTR_WARN_UNUSED __attribute__ ((warn_unused_result))
#else
#define OSRM_ATTR_WARN_UNUSED
#endif
#endif
+2
View File
@@ -6,6 +6,7 @@
#include "extractor/guidance/turn_instruction.hpp"
#include "engine/guidance/route_step.hpp"
#include "engine/phantom_node.hpp"
#include "util/attributes.hpp"
#include "util/guidance/bearing_class.hpp"
#include "util/guidance/entry_class.hpp"
#include "util/simple_logger.hpp"
@@ -50,6 +51,7 @@ inline extractor::guidance::DirectionModifier::Enum getTurnDirection(const doubl
}
// swaps left <-> right modifier types
OSRM_ATTR_WARN_UNUSED
inline extractor::guidance::DirectionModifier::Enum
mirrorDirectionModifier(const extractor::guidance::DirectionModifier::Enum modifier)
{