The branch, master has been updated
       via  e2392729f33 libsmbconf: Avoid initial declaration inside 'for' loop
      from  84480a1e21f python/samba/tests: add SMBConfTests suite

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit e2392729f33a48a4a4e891a84a1556c802a8d344
Author: Anoop C S <anoo...@samba.org>
Date:   Mon Apr 25 12:24:28 2022 +0530

    libsmbconf: Avoid initial declaration inside 'for' loop
    
    Building Samba on CentOS 7 with GCC version 4.8.5 results in the
    following error:
    
    [2725/3398] Compiling libcli/echo/tests/echo.c
    ../../lib/smbconf/pysmbconf.c: In function 'py_from_smbconf_service':
    ../../lib/smbconf/pysmbconf.c:72:2: error: 'for' loop initial
                                   declarations are only allowed in C99 mode
      for (uint32_t i = 0; i < svc->num_params; i++) {
      ^
    ../../lib/smbconf/pysmbconf.c:72:2: note: use option -std=c99 or
                                             -std=gnu99 to compile your code
    ../../lib/smbconf/pysmbconf.c: In function 'obj_share_names':
    ../../lib/smbconf/pysmbconf.c:181:2: error: 'for' loop initial
                                   declarations are only allowed in C99 mode
      for (uint32_t i = 0; i < num_shares; i++) {
      ^
    ../../lib/smbconf/pysmbconf.c: In function 'obj_get_config':
    ../../lib/smbconf/pysmbconf.c:267:2: error: 'for' loop initial
                                   declarations are only allowed in C99 mode
      for (uint32_t i = 0; i < num_shares; i++) {
      ^
    
    Therefore declare variables right at the start aligning to default C90
    standard available with GCC version on CentOS 7.
    
    Signed-off-by: Anoop C S <anoo...@samba.org>
    Reviewed-by: Andreas Schneider <a...@samba.org>
    
    Autobuild-User(master): Andreas Schneider <a...@cryptomilk.org>
    Autobuild-Date(master): Mon Apr 25 13:23:18 UTC 2022 on sn-devel-184

-----------------------------------------------------------------------

Summary of changes:
 lib/smbconf/pysmbconf.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/smbconf/pysmbconf.c b/lib/smbconf/pysmbconf.c
index 0a5c3a6980c..abf77ddc1eb 100644
--- a/lib/smbconf/pysmbconf.c
+++ b/lib/smbconf/pysmbconf.c
@@ -64,20 +64,21 @@ static void py_raise_SMBConfError(sbcErr err)
  */
 static PyObject *py_from_smbconf_service(struct smbconf_service *svc)
 {
+       uint32_t count;
        PyObject *plist = PyList_New(svc->num_params);
        if (plist == NULL) {
                return NULL;
        }
 
-       for (uint32_t i = 0; i < svc->num_params; i++) {
+       for (count = 0; count < svc->num_params; count++) {
                PyObject *pt = Py_BuildValue("(ss)",
-                                            svc->param_names[i],
-                                            svc->param_values[i]);
+                                            svc->param_names[count],
+                                            svc->param_values[count]);
                if (pt == NULL) {
                        Py_CLEAR(plist);
                        return NULL;
                }
-               if (PyList_SetItem(plist, i, pt) < 0) {
+               if (PyList_SetItem(plist, count, pt) < 0) {
                        Py_CLEAR(pt);
                        Py_CLEAR(plist);
                        return NULL;
@@ -149,6 +150,7 @@ static PyObject *obj_share_names(py_SMBConf_Object * self,
                                 PyObject * Py_UNUSED(ignored))
 {
        sbcErr err;
+       uint32_t count;
        uint32_t num_shares;
        char **share_names = NULL;
        PyObject *slist = NULL;
@@ -178,14 +180,14 @@ static PyObject *obj_share_names(py_SMBConf_Object * self,
                talloc_free(mem_ctx);
                return NULL;
        }
-       for (uint32_t i = 0; i < num_shares; i++) {
-               PyObject *ustr = PyUnicode_FromString(share_names[i]);
+       for (count = 0; count < num_shares; count++) {
+               PyObject *ustr = PyUnicode_FromString(share_names[count]);
                if (ustr == NULL) {
                        Py_CLEAR(slist);
                        talloc_free(mem_ctx);
                        return NULL;
                }
-               if (PyList_SetItem(slist, i, ustr) < 0) {
+               if (PyList_SetItem(slist, count, ustr) < 0) {
                        Py_CLEAR(ustr);
                        Py_CLEAR(slist);
                        talloc_free(mem_ctx);
@@ -239,6 +241,7 @@ static PyObject *obj_get_config(py_SMBConf_Object * self,
        sbcErr err;
        PyObject *svclist = NULL;
        TALLOC_CTX *mem_ctx = NULL;
+       uint32_t count;
        uint32_t num_shares;
        struct smbconf_service **svcs = NULL;
 
@@ -264,14 +267,14 @@ static PyObject *obj_get_config(py_SMBConf_Object * self,
                talloc_free(mem_ctx);
                return NULL;
        }
-       for (uint32_t i = 0; i < num_shares; i++) {
-               PyObject *svcobj = py_from_smbconf_service(svcs[i]);
+       for (count = 0; count < num_shares; count++) {
+               PyObject *svcobj = py_from_smbconf_service(svcs[count]);
                if (svcobj == NULL) {
                        Py_CLEAR(svclist);
                        talloc_free(mem_ctx);
                        return NULL;
                }
-               if (PyList_SetItem(svclist, i, svcobj) < 0) {
+               if (PyList_SetItem(svclist, count, svcobj) < 0) {
                        Py_CLEAR(svcobj);
                        Py_CLEAR(svclist);
                        talloc_free(mem_ctx);


-- 
Samba Shared Repository

Reply via email to