<p>Like <a href="https://github.com/codebrainz" class="user-mention">@codebrainz</a> I think the original is acceptable, its a cheap test of a return from a function that documents if can return NULL, even if the current context prevents it, and I agree that it is nice to warn the programmer if we think of it.</p>
<p>But like <a href="https://github.com/vfaronov" class="user-mention">@vfaronov</a> I do not think its a good idea to add crashes that may leak to the user depending on how the distro builds Geany (ie including asserts or not).</p>
<p>So what about leaving the initial <code>if (doc)</code>  test so it can't crash, but put:</p>
<pre><code>if (!doc)g_critical("@vfaranov was right");
</code></pre>
<p>before the test so it then logs a message, and can be made fatal by setting the <code>G_DEBUG</code> environment variable.  GTK does this lots.</p>
<p>PS any sensible message will do :-D</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/geany/geany/pull/1537#issuecomment-315500275">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABDrJ5QTfFNciDAoma-SOi95HjSEAK5eks5sOBVygaJpZM4OR0zM">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/ABDrJ_zvLk8GMDpgMNVX3CRRlkjD2I5Eks5sOBVygaJpZM4OR0zM.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/geany/geany/pull/1537#issuecomment-315500275"></link>
  <meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>

<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/geany/geany","title":"geany/geany","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/geany/geany"}},"updates":{"snippets":[{"icon":"PERSON","message":"@elextr in #1537: Like @codebrainz I think the original is acceptable, its a cheap test of a return from a function that documents if can return NULL, even if the current context prevents it, and I agree that it is nice to warn the programmer if we think of it.\r\n\r\nBut like @vfaronov I do not think its a good idea to add crashes that may leak to the user depending on how the distro builds Geany (ie including asserts or not).\r\n\r\nSo what about leaving the initial `if (doc)`  test so it can't crash, but put:\r\n```\r\nif (!doc)g_critical(\"@vfaranov was right\");\r\n``` \r\n\r\nbefore the test so it then logs a message, and can be made fatal by setting the `G_DEBUG` environment variable.  GTK does this lots.\r\n\r\nPS any sensible message will do :-D\r\n"}],"action":{"name":"View Pull Request","url":"https://github.com/geany/geany/pull/1537#issuecomment-315500275"}}}</script>