<p>I asked Miklos (initial author of that code) and he clarified quickly: the reason for <code>-1</code> is to get rid of the byte of the field <code>unsigned char vars[1]</code> from the <code>struct _cfg_block</code>.</p>
<p>He spotted that sizeof(cfg_block_t) is 8 on your system, while it should be 9:</p>
<pre><code> /*! \brief single memoy block that contains all the cfg values */
typedef struct _cfg_block {
        atomic_t        refcnt;         /*!< reference counter,
                                        the block is automatically deleted
                                        when it reaches 0 */
        int             _pad;           /*!< force 8 byte alignment */
        unsigned char   vars[1];        /*!< blob that contains the values */
} cfg_block_t;
</code></pre>
<p>What version of kamailio are you using? Compiled by yourself or from packages built by the project? Also, what is the operating system and kernel (uname -a) versions?</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/issues/1583#issuecomment-402708004">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AF36ZZNX1qiU_fr4UFmXV8kPo4XNqAgbks5uDgiXgaJpZM4VDDlj">mute the thread</a>.<img src="https://github.com/notifications/beacon/AF36ZVvoi5Ghi3OTx6WnCPFBE61Nfxxaks5uDgiXgaJpZM4VDDlj.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":"@miconda in #1583: I asked Miklos (initial author of that code) and he clarified quickly: the reason for `-1` is to get rid of the byte of the field `unsigned char vars[1]` from the `struct _cfg_block`.\r\n\r\nHe spotted that sizeof(cfg_block_t) is 8 on your system, while it should be 9:\r\n\r\n```\r\n /*! \\brief single memoy block that contains all the cfg values */\r\ntypedef struct _cfg_block {\r\n\tatomic_t\trefcnt;\t\t/*!\u003c reference counter,\r\n\t\t\t\t\tthe block is automatically deleted\r\n\t\t\t\t\twhen it reaches 0 */\r\n\tint\t\t_pad;\t\t/*!\u003c force 8 byte alignment */\r\n\tunsigned char\tvars[1];\t/*!\u003c blob that contains the values */\r\n} cfg_block_t;\r\n```\r\n\r\nWhat version of kamailio are you using? Compiled by yourself or from packages built by the project? Also, what is the operating system and kernel (uname -a) versions?"}],"action":{"name":"View Issue","url":"https://github.com/kamailio/kamailio/issues/1583#issuecomment-402708004"}}}</script>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/kamailio/kamailio/issues/1583#issuecomment-402708004",
"url": "https://github.com/kamailio/kamailio/issues/1583#issuecomment-402708004",
"name": "View Issue"
},
"description": "View this Issue 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] cfg_rpc updates changing variable values to large random numbers  (#1583)",
"sections": [
{
"text": "",
"activityTitle": "**Daniel-Constantin Mierla**",
"activityImage": "https://assets-cdn.github.com/images/email/message_cards/avatar.png",
"activitySubtitle": "@miconda",
"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\": 1583,\n\"IssueComment\": \"{{IssueComment.value}}\"\n}"
}
]
},
{
"name": "Close issue",
"@type": "HttpPOST",
"target": "https://api.github.com",
"body": "{\n\"commandName\": \"IssueClose\",\n\"repositoryFullName\": \"kamailio/kamailio\",\n\"issueId\": 1583\n}"
},
{
"targets": [
{
"os": "default",
"uri": "https://github.com/kamailio/kamailio/issues/1583#issuecomment-402708004"
}
],
"@type": "OpenUri",
"name": "View on GitHub"
},
{
"name": "Unsubscribe",
"@type": "HttpPOST",
"target": "https://api.github.com",
"body": "{\n\"commandName\": \"MuteNotification\",\n\"threadId\": 353122659\n}"
}
],
"themeColor": "26292E"
}
]</script>