<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html lang="en">
<head>
<meta content="text/html; charset=US-ASCII" http-equiv="Content-Type">
<title>
GitLab
</title>
<style>img {
max-width: 100%; height: auto;
}
</style>
</head>
<body>
<div class="content">
<p class="details" style="font-style: italic; color: #777;">
<a href="https://gitlab.com/dueno">Daiki Ueno</a> created a merge request:
</p>
<p>
</p>
<div class="branch">
Branches: tmp-static-assert to master
</div>
<div class="author">
Author: Daiki Ueno
</div>
<div class="assignee">
Assignees:
</div>
<div class="approvers">
</div>
<div>
<p dir="auto">We previously had checks of enum values with '#if', such as below:</p>
<pre class="code highlight js-syntax-highlight c" lang="c" v-pre="true"><code><span id="LC1" class="line" lang="c"><span class="cp">#define GNUTLS_EXTENSION_MAX_VALUE 31</span></span>
<span id="LC2" class="line" lang="c"></span>
<span id="LC3" class="line" lang="c"><span class="k">typedef</span> <span class="k">enum</span> <span class="n">extensions_t</span> <span class="p">{</span></span>
<span id="LC4" class="line" lang="c"> <span class="p">...</span></span>
<span id="LC5" class="line" lang="c"> <span class="n">GNUTLS_EXTENSION_MAX</span> <span class="cm">/* not real extension - used for iterators */</span></span>
<span id="LC6" class="line" lang="c"><span class="p">}</span> <span class="n">extensions_t</span><span class="p">;</span></span>
<span id="LC7" class="line" lang="c"></span>
<span id="LC8" class="line" lang="c"><span class="cm">/* we must provide at least 16 extensions for users to register */</span></span>
<span id="LC9" class="line" lang="c"><span class="cp">#if GNUTLS_EXTENSION_MAX_VALUE - GNUTLS_EXTENSION_MAX < 16</span></span>
<span id="LC10" class="line" lang="c"><span class="cp"># error not enough extension types</span></span>
<span id="LC11" class="line" lang="c"><span class="cp">#endif</span></span></code></pre>
<p dir="auto">This doesn't work as expected; because <code>GNUTLS_EXTENSION_MAX</code> is not
defined as a preprocessor macro, it always expands to 0. To properly
do this check, we need to use static assert as provided as the
'verify' macro in gnulib.</p>
<h2 dir="auto">
<a id="user-content-checklist" class="anchor" href="#checklist" aria-hidden="true"></a>Checklist</h2>
<ul class="task-list" dir="auto">
<li class="task-list-item">
<input type="checkbox" class="task-list-item-checkbox" checked disabled> Commits have <code>Signed-off-by:</code> with name/author being identical to the commit author</li>
<li class="task-list-item">
<input type="checkbox" class="task-list-item-checkbox" disabled> Code modified for feature</li>
<li class="task-list-item">
<input type="checkbox" class="task-list-item-checkbox" disabled> Test suite updated with functionality tests</li>
<li class="task-list-item">
<input type="checkbox" class="task-list-item-checkbox" disabled> Test suite updated with negative tests</li>
<li class="task-list-item">
<input type="checkbox" class="task-list-item-checkbox" disabled> Documentation updated / NEWS entry present (for non-trivial changes)</li>
<li class="task-list-item">
<input type="checkbox" class="task-list-item-checkbox" disabled> CI timeout is 2h or higher (see Settings/CICD/General pipelines/Timeout)</li>
</ul>
<h2 dir="auto">
<a id="user-content-reviewers-checklist" class="anchor" href="#reviewers-checklist" aria-hidden="true"></a>Reviewer's checklist:</h2>
<ul class="task-list" dir="auto">
<li class="task-list-item">
<input type="checkbox" class="task-list-item-checkbox" disabled> Any issues marked for closing are addressed</li>
<li class="task-list-item">
<input type="checkbox" class="task-list-item-checkbox" disabled> There is a test suite reasonably covering new functionality or modifications</li>
<li class="task-list-item">
<input type="checkbox" class="task-list-item-checkbox" disabled> Function naming, parameters, return values, types, etc., are consistent and according to <code>CONTRIBUTION.md</code>
</li>
<li class="task-list-item">
<input type="checkbox" class="task-list-item-checkbox" disabled> This feature/change has adequate documentation added</li>
<li class="task-list-item">
<input type="checkbox" class="task-list-item-checkbox" disabled> No obvious mistakes in the code</li>
</ul>
</div>
</div>
<div class="footer" style="margin-top: 10px;">
<p style="font-size: small; color: #777;">
—
<br>
Reply to this email directly or <a href="https://gitlab.com/gnutls/gnutls/-/merge_requests/1201">view it on GitLab</a>.
<br>
You're receiving this email because of your account on gitlab.com.
If you'd like to receive fewer emails, you can
<a href="https://gitlab.com/sent_notifications/55c0d2059d0bab3d98a2af15e1cf6305/unsubscribe">unsubscribe</a>
from this thread or
adjust your notification settings.
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":"View Merge request","url":"https://gitlab.com/gnutls/gnutls/-/merge_requests/1201"}}</script>
</p>
</div>
</body>
</html>