Converting integers with different capacity
<p>I have the following code:</p>

<pre><code>// ---- third party library code ----
struct Point { int16_t x, y; };
void third_party_library__getPoint(Point*);
void third_party_library__setPoint(const Point*);

// ---- my library code ----
void move_point(int dx, int dy)
{
    Point pt;
    third_party_library__getPoint(&amp;pt);
    pt.x += dx;
    pt.y += dy;
    third_party_library__setPoint(&amp;pt);
}
</code></pre>

<p>Line <code>pt.x += dx;</code> yields warning<br>
<code>conversion from 'int' to 'int16_t', possible loss of data</code></p>

<p>What should I do?</p>

<ol>
<li>disable warning for those lines</li>
<li>move the source of warning to interface: make <code>dx</code> and <code>dy</code> int16_t, so one who will use <code>move_point</code> function will deal with this problem.</li>
<li>just cast <code>dx</code> and <code>dy</code> to int16_t.</li>
<li>add <code>assert(dx &lt;= 0x7FFF &amp;&amp; dx &gt;= -0x8000 &amp;&amp; "too large 'dx' value")</code> and hope that it will hit when I will run debug version.</li>
</ol>
