<p>Hi Hennig, thanks for the review so far.</p>
<p>Q: "you want to unify the flag manipulation and also fix some bugs this way?"<br>
A: Correct, to fix the bug we need to change inconsitant flag manipulation creating the bug</p>
<p>Q: This should be identically, according to the definition of isflagset. I don't see any big advantage of one format to the other, or I am wrong?<br>
A: They are not identical :</p>
<p>The first one is expecting an input we the integer contain the bit mask<br>
<code>if((type==1) && (msg->flags&(e->missed_flag))) {</code><br>
will with with the input of : 1,2,4,8,...,4294967296</p>
<p>The second one is expecting an input where integer contain the bit position<br>
<code>if((type==1) && isflagset(msg, e->missed_flag) == 1) {</code><br>
will do the bit shifting and will work with the input : 1,2,3,..,32</p>
<pre><code>int isflagset( struct sip_msg* msg, flag_t flag ) {
return (msg->flags & (1<<flag)) ? 1 : -1; // << notice the bit shifting
}
</code></pre>
<p><code>resetflag</code> and <code>setflag</code> are also doing the bit shifthing, seems like at one point someone got confused and introduce a mix which endedup doing resetflag on an alredy bit shifted input.<br>
I guess this is also why acc_mod is not doing bit shifting on the module param while acc_diameter, acc_raduis and acc_json are (I am changing this in the patch)</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/kamailio/kamailio/pull/1674#issuecomment-429329716">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AF36ZfrR-QSY2qauuHd5VZ8_Pqt0TUnkks5ukJwsgaJpZM4XYVgP">mute the thread</a>.<img src="https://github.com/notifications/beacon/AF36ZcqKZtaRpk9AY2bqRI7rtyp59DOrks5ukJwsgaJpZM4XYVgP.gif" height="1" width="1" alt="" /></p>
<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/kamailio/kamailio","title":"kamailio/kamailio","subtitle":"GitHub repository","main_image_url":"https://assets-cdn.github.com/images/email/message_cards/header.png","avatar_image_url":"https://assets-cdn.github.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/kamailio/kamailio"}},"updates":{"snippets":[{"icon":"PERSON","message":"@jchavanton in #1674: Hi Hennig, thanks for the review so far.\r\n\r\nQ: \"you want to unify the flag manipulation and also fix some bugs this way?\"\r\nA: Correct, to fix the bug we need to change inconsitant flag manipulation creating the bug \r\n\r\nQ: This should be identically, according to the definition of isflagset. I don't see any big advantage of one format to the other, or I am wrong?\r\nA: They are not identical :\r\n\r\nThe first one is expecting an input we the integer contain the bit mask\r\n`if((type==1) \u0026\u0026 (msg-\u003eflags\u0026(e-\u003emissed_flag))) {` \r\nwill with with the input of : 1,2,4,8,...,4294967296\r\n\r\nThe second one is expecting an input where integer contain the bit position\r\n`if((type==1) \u0026\u0026 isflagset(msg, e-\u003emissed_flag) == 1) {`\r\nwill do the bit shifting and will work with the input : 1,2,3,..,32\r\n\r\n```\r\nint isflagset( struct sip_msg* msg, flag_t flag ) {\r\n return (msg-\u003eflags \u0026 (1\u003c\u003cflag)) ? 1 : -1; // \u003c\u003c notice the bit shifting\r\n}\r\n```\r\n\r\n`resetflag` and `setflag` are also doing the bit shifthing, seems like at one point someone got confused and introduce a mix which endedup doing resetflag on an alredy bit shifted input.\r\nI guess this is also why acc_mod is not doing bit shifting on the module param while acc_diameter, acc_raduis and acc_json are (I am changing this in the patch) \r\n"}],"action":{"name":"View Pull Request","url":"https://github.com/kamailio/kamailio/pull/1674#issuecomment-429329716"}}}</script>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/kamailio/kamailio/pull/1674#issuecomment-429329716",
"url": "https://github.com/kamailio/kamailio/pull/1674#issuecomment-429329716",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
},
{
"@type": "MessageCard",
"@context": "http://schema.org/extensions",
"hideOriginalBody": "false",
"originator": "AF6C5A86-E920-430C-9C59-A73278B5EFEB",
"title": "Re: [kamailio/kamailio] acc: generating duplicates (#1674)",
"sections": [
{
"text": "",
"activityTitle": "**Julien Chavanton**",
"activityImage": "https://assets-cdn.github.com/images/email/message_cards/avatar.png",
"activitySubtitle": "@jchavanton",
"facts": [
]
}
],
"potentialAction": [
{
"name": "Add a comment",
"@type": "ActionCard",
"inputs": [
{
"isMultiLine": true,
"@type": "TextInput",
"id": "IssueComment",
"isRequired": false
}
],
"actions": [
{
"name": "Comment",
"@type": "HttpPOST",
"target": "https://api.github.com",
"body": "{\n\"commandName\": \"IssueComment\",\n\"repositoryFullName\": \"kamailio/kamailio\",\n\"issueId\": 1674,\n\"IssueComment\": \"{{IssueComment.value}}\"\n}"
}
]
},
{
"name": "Close pull request",
"@type": "HttpPOST",
"target": "https://api.github.com",
"body": "{\n\"commandName\": \"PullRequestClose\",\n\"repositoryFullName\": \"kamailio/kamailio\",\n\"pullRequestId\": 1674\n}"
},
{
"targets": [
{
"os": "default",
"uri": "https://github.com/kamailio/kamailio/pull/1674#issuecomment-429329716"
}
],
"@type": "OpenUri",
"name": "View on GitHub"
},
{
"name": "Unsubscribe",
"@type": "HttpPOST",
"target": "https://api.github.com",
"body": "{\n\"commandName\": \"MuteNotification\",\n\"threadId\": 392255503\n}"
}
],
"themeColor": "26292E"
}
]</script>