<!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 style="color: #777777;">
<a href="https://gitlab.com/nmav">Nikos Mavrogiannopoulos</a>
commented on a
discussion on <a href="https://gitlab.com/gnutls/gnutls/merge_requests/1092#note_230554687">lib/str.c</a>:
</p>
<table>
<tr class="line_holder" id="">
<td class="diff-line-num old_line" data-linenumber="289" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
289
</td>
<td class="diff-line-num new_line" data-linenumber="289" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
289
</td>
<td class="line_content" style="padding-left: 0.5em; padding-right: 0.5em;">
<pre style="margin: 0;"> <span id="LC289" class="line" lang="c">    <span class="n" style="color: #333;">gnutls_datum_t</span> <span class="n" style="color: #333;">tdata</span><span class="p">;</span></span>
</pre>
</td>
</tr>
<tr class="line_holder" id="">
<td class="diff-line-num old_line" data-linenumber="290" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
290
</td>
<td class="diff-line-num new_line" data-linenumber="290" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
290
</td>
<td class="line_content" style="padding-left: 0.5em; padding-right: 0.5em;">
<pre style="margin: 0;"> <span id="LC290" class="line" lang="c"></span>
</pre>
</td>
</tr>
<tr class="line_holder" id="">
<td class="diff-line-num old_line" data-linenumber="291" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
291
</td>
<td class="diff-line-num new_line" data-linenumber="291" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
291
</td>
<td class="line_content" style="padding-left: 0.5em; padding-right: 0.5em;">
<pre style="margin: 0;"> <span id="LC291" class="line" lang="c">    <span class="n" style="color: #333;">_gnutls_buffer_pop_datum</span><span class="p">(</span><span class="n" style="color: #333;">str</span><span class="p">,</span> <span class="o" style="font-weight: 600;">&</span><span class="n" style="color: #333;">tdata</span><span class="p">,</span> <span class="n" style="color: #333;">req_size</span><span class="p">);</span></span>
</pre>
</td>
</tr>
<tr class="line_holder old" id="">
<td class="diff-line-num old old_line" data-linenumber="292" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #fac5cd; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#f9d7dc">
292
</td>
<td class="diff-line-num new_line old" data-linenumber="292" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #fac5cd; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#f9d7dc">
 
</td>
<td class="line_content old" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#fbe9eb">
<pre style="margin: 0;">-<span id="LC292" class="line" lang="c">    <span class="k" style="font-weight: 600;">if</span> <span class="p">(</span><span class="n" style="color: #333;">tdata</span><span class="p">.</span><span class="n" style="color: #333;">data</span> <span class="o" style="font-weight: 600;">==</span> <span class="nb" style="color: #0086b3;">NULL</span> <span class="o" style="font-weight: 600;">||</span> <span class="n" style="color: #333;">tdata</span><span class="p">.</span><span class="n" style="color: #333;">size</span> <span class="o" style="font-weight: 600;"><span class="idiff left right">!=</span></span> <span class="n" style="color: #333;">req_size</span><span class="p">)</span> <span class="p">{</span></span>
</pre>
</td>
</tr>
<tr class="line_holder new" id="">
<td class="diff-line-num new old_line" data-linenumber="293" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
 
</td>
<td class="diff-line-num new new_line" data-linenumber="292" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
292
</td>
<td class="line_content new" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#ecfdf0">
<pre style="margin: 0;">+<span id="LC292" class="line" lang="c">    <span class="k" style="font-weight: 600;">if</span> <span class="p">(</span><span class="n" style="color: #333;">tdata</span><span class="p">.</span><span class="n" style="color: #333;">data</span> <span class="o" style="font-weight: 600;">==</span> <span class="nb" style="color: #0086b3;">NULL</span> <span class="o" style="font-weight: 600;">||</span> <span class="n" style="color: #333;">tdata</span><span class="p">.</span><span class="n" style="color: #333;">size</span> <span class="o" style="font-weight: 600;"><span class="idiff left right">></span></span> <span class="n" style="color: #333;">req_size</span><span class="p">)</span> <span class="p">{</span></span>
</pre>
</td>
</tr>

</table>
<div style="">
<p dir="auto">btw. what this function does, if you ask 2 bytes, it will always give you two bytes. If the struct has 4 bytes, that's fine, it will still give you two bytes (because of the pop_datum call). It will fail when the structure did not have enough data stored (e.g., asked for 2 while it has only 1). You can see how it is used in practice in <code>hello_retry.c</code></p>
</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/1092#note_230554687">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/8a81c382f3fcb4a0a4f79d62ed8dd0b1/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/1092#note_230554687"}}</script>


</p>
</div>
</body>
</html>