All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] libselinux: add a const to suppress a build warning with Python 3.7
@ 2018-08-19 18:48 Nicolas Iooss
  2018-08-19 18:49 ` [PATCH 2/3] Travis-CI: upgrade to Ubuntu 16.04 LTS Xenial Xerus Nicolas Iooss
  2018-08-19 18:49 ` [PATCH 3/3] python: remove semicolon from end of lines Nicolas Iooss
  0 siblings, 2 replies; 5+ messages in thread
From: Nicolas Iooss @ 2018-08-19 18:48 UTC (permalink / raw)
  To: selinux

On systems using Python 3.7, when compiling libselinux Python wrappers
(with "make install-pywrap"), the following warning is reported by gcc:

    audit2why.c: In function ‘analyze’:
    audit2why.c:364:11: warning: assignment discards ‘const’ qualifier
    from pointer target type [-Wdiscarded-qualifiers]
       permstr = _PyUnicode_AsString( strObj );
               ^

Make permstr "const char *" in order to suppress this warning.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
---
 libselinux/src/audit2why.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libselinux/src/audit2why.c b/libselinux/src/audit2why.c
index 0331fdfd8df9..5a1e69a8269b 100644
--- a/libselinux/src/audit2why.c
+++ b/libselinux/src/audit2why.c
@@ -354,7 +354,7 @@ static PyObject *analyze(PyObject *self __attribute__((unused)) , PyObject *args
 	/* iterate over items of the list, grabbing strings, and parsing
 	   for numbers */
 	for (i=0; i<numlines; i++){
-		char *permstr;
+		const char *permstr;
 
 		/* grab the string object from the next element of the list */
 		strObj = PyList_GetItem(listObj, i); /* Can't fail */
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] Travis-CI: upgrade to Ubuntu 16.04 LTS Xenial Xerus
  2018-08-19 18:48 [PATCH 1/3] libselinux: add a const to suppress a build warning with Python 3.7 Nicolas Iooss
@ 2018-08-19 18:49 ` Nicolas Iooss
  2018-08-19 18:49 ` [PATCH 3/3] python: remove semicolon from end of lines Nicolas Iooss
  1 sibling, 0 replies; 5+ messages in thread
From: Nicolas Iooss @ 2018-08-19 18:49 UTC (permalink / raw)
  To: selinux

Ubuntu 14.04 uses SWIG 2.0.11 which produces Python files which contain
lines ending with a semicolon:

    __del__ = lambda self : None;

Ubuntu 16.04 uses SWIG 3.0.8, which does not put a semicolon. Moreover
Travis CI only support Python 3.7 with Ubuntu 16.04. The reason for this
is clearly stated on
https://docs.travis-ci.com/user/languages/python/#development-releases-support :

    Recent Python branches require OpenSSL 1.0.2+. As this library is
    not available for Trusty, 3.7, 3.7-dev, 3.8-dev, and nightly do not
    work (or use outdated archive).

Enabling Python 3.7 in Travis CI build matrix is therefore another
reason to upgrade .travis.yml to Ubuntu 16.04. As this new template does
not support Python 3.4 nor 3.5, and does not support PyPy2.7 yet, drop
them from the build matrix.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
---
 .travis.yml | 36 +++++++++++++++++-------------------
 1 file changed, 17 insertions(+), 19 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 09dd4749975e..00d0c54a68d7 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -11,34 +11,35 @@ compiler:
 env:
   matrix:
     # Test the last version of Python and Ruby together, with some linkers
-    - PYVER=python3.6 RUBYLIBVER=2.5.1
-    - PYVER=python3.6 RUBYLIBVER=2.5.1 TEST_FLAGS_OVERRIDE=1
-    - PYVER=python3.6 RUBYLIBVER=2.5.1 LINKER=gold
-    - PYVER=python3.6 RUBYLIBVER=2.5.1 LINKER=bfd
+    - PYVER=python3.7 RUBYLIBVER=2.5.1
+    - PYVER=python3.7 RUBYLIBVER=2.5.1 TEST_FLAGS_OVERRIDE=1
+    - PYVER=python3.7 RUBYLIBVER=2.5.1 LINKER=gold
+    - PYVER=python3.7 RUBYLIBVER=2.5.1 LINKER=bfd
 
     # Test several Python versions
     - PYVER=python2.7 RUBYLIBVER=2.5.1
-    - PYVER=python3.3 RUBYLIBVER=2.5.1
-    - PYVER=python3.4 RUBYLIBVER=2.5.1
     - PYVER=python3.5 RUBYLIBVER=2.5.1
-    - PYVER=pypy RUBYLIBVER=2.5.1
-    - PYVER=pypy3 RUBYLIBVER=2.5.1
+    - PYVER=python3.6 RUBYLIBVER=2.5.1
+    # pypy2.7 seems not to be available in Travis-CI Xenial template yet.
+    # https://github.com/travis-ci/travis-ci/issues/9542
+    #- PYVER=pypy RUBYLIBVER=2.5.1
+    - PYVER=pypy3.5 RUBYLIBVER=2.5.1
 
     # Test several Ruby versions
-    - PYVER=python3.6 RUBYLIBVER=2.4
-    - PYVER=python3.6 RUBYLIBVER=2.3
-    - PYVER=python3.6 RUBYLIBVER=2.2
+    - PYVER=python3.7 RUBYLIBVER=2.4
+    - PYVER=python3.7 RUBYLIBVER=2.3
+    - PYVER=python3.7 RUBYLIBVER=2.2
 
 matrix:
   exclude:
     - compiler: clang
-      env: PYVER=python3.6 RUBYLIBVER=2.5.1 LINKER=gold
+      env: PYVER=python3.7 RUBYLIBVER=2.5.1 LINKER=gold
     - compiler: clang
-      env: PYVER=python3.6 RUBYLIBVER=2.5.1 LINKER=bfd
+      env: PYVER=python3.7 RUBYLIBVER=2.5.1 LINKER=bfd
 
-# Use Travis-CI Ubuntu 14.04 Trusty infrastructure, "full image" variant
+# Use Travis-CI Ubuntu 16.04 Xenial Xerus infrastructure, "full image" variant
 sudo: required
-dist: trusty
+dist: xenial
 
 # Install SELinux userspace utilities dependencies
 addons:
@@ -78,7 +79,7 @@ install:
   # Download the required python version if it is not installed
   - VIRTUAL_ENV="$HOME/virtualenv/$PYVER"
   - if ! [ -d "$VIRTUAL_ENV" ] ; then
-        curl --retry 10 -o python.tar.bz2 "https://s3.amazonaws.com/travis-python-archives/binaries/ubuntu/14.04/x86_64/${PYVER/python/python-}.tar.bz2" &&
+        curl --retry 10 -o python.tar.bz2 "https://s3.amazonaws.com/travis-python-archives/binaries/ubuntu/16.04/x86_64/${PYVER/python/python-}.tar.bz2" &&
         sudo tar xjf python.tar.bz2 --directory / &&
         rm python.tar.bz2 ;
     fi
@@ -87,9 +88,6 @@ install:
   - $VIRTUAL_ENV/bin/pip install flake8
 
 before_script:
-  # clang on Travis-CI 14.04 environment is too old to support -Wdouble-promotion
-  - if "$CC" --version |grep -q clang; then sed 's/ -Wdouble-promotion / /' -i libselinux/src/Makefile libselinux/utils/Makefile ; fi
-
   # Build and install in a temporary directory to run tests
   - export DESTDIR="$TRAVIS_BUILD_DIR/installdir"
 
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] python: remove semicolon from end of lines
  2018-08-19 18:48 [PATCH 1/3] libselinux: add a const to suppress a build warning with Python 3.7 Nicolas Iooss
  2018-08-19 18:49 ` [PATCH 2/3] Travis-CI: upgrade to Ubuntu 16.04 LTS Xenial Xerus Nicolas Iooss
@ 2018-08-19 18:49 ` Nicolas Iooss
  2018-08-20 21:51   ` William Roberts
  1 sibling, 1 reply; 5+ messages in thread
From: Nicolas Iooss @ 2018-08-19 18:49 UTC (permalink / raw)
  To: selinux

Python does not need to end a statement with a semicolon. Doing this
gets reported by linters such as flake8 ("E703 statement ends with a
semicolon").

Remove such semicolons in the code and enable this warning in
scripts/run-flake8.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
---
 python/sepolgen/src/sepolgen/audit.py | 2 +-
 python/sepolgen/src/sepolgen/yacc.py  | 8 ++++----
 python/sepolicy/sepolicy/manpage.py   | 2 +-
 scripts/run-flake8                    | 1 -
 4 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/python/sepolgen/src/sepolgen/audit.py b/python/sepolgen/src/sepolgen/audit.py
index daed58ce9643..4adb851f3e93 100644
--- a/python/sepolgen/src/sepolgen/audit.py
+++ b/python/sepolgen/src/sepolgen/audit.py
@@ -258,7 +258,7 @@ class AVCMessage(AuditMessage):
         if (scontext, tcontext, self.tclass, access_tuple) in avcdict.keys():
             self.type, self.data = avcdict[(scontext, tcontext, self.tclass, access_tuple)]
         else:
-            self.type, self.data = audit2why.analyze(scontext, tcontext, self.tclass, self.accesses);
+            self.type, self.data = audit2why.analyze(scontext, tcontext, self.tclass, self.accesses)
             if self.type == audit2why.NOPOLICY:
                 self.type = audit2why.TERULE
             if self.type == audit2why.BADTCON:
diff --git a/python/sepolgen/src/sepolgen/yacc.py b/python/sepolgen/src/sepolgen/yacc.py
index f00635469af1..afef174849f2 100644
--- a/python/sepolgen/src/sepolgen/yacc.py
+++ b/python/sepolgen/src/sepolgen/yacc.py
@@ -1864,10 +1864,10 @@ del _lr_action_items
 """)
             
         else:
-            f.write("\n_lr_action = { ");
+            f.write("\n_lr_action = { ")
             for k,v in _lr_action.items():
                 f.write("(%r,%r):%r," % (k[0],k[1],v))
-            f.write("}\n");
+            f.write("}\n")
 
         if smaller:
             # Factor out names to try and make smaller
@@ -1901,10 +1901,10 @@ for _k, _v in _lr_goto_items.items():
 del _lr_goto_items
 """)
         else:
-            f.write("\n_lr_goto = { ");
+            f.write("\n_lr_goto = { ")
             for k,v in _lr_goto.items():
                 f.write("(%r,%r):%r," % (k[0],k[1],v))                    
-            f.write("}\n");
+            f.write("}\n")
 
         # Write production table
         f.write("_lr_productions = [\n")
diff --git a/python/sepolicy/sepolicy/manpage.py b/python/sepolicy/sepolicy/manpage.py
index cb211ba083ca..cfcb7c3932d7 100755
--- a/python/sepolicy/sepolicy/manpage.py
+++ b/python/sepolicy/sepolicy/manpage.py
@@ -539,7 +539,7 @@ class ManPage:
                     self.fd = fd
                     self.man_page_path = man_page_path
             except KeyError:
-                continue;
+                continue
             self.attributes[domain_type] = next(sepolicy.info(sepolicy.TYPE, ("%s") % domain_type))["attributes"]
 
         self._header()
diff --git a/scripts/run-flake8 b/scripts/run-flake8
index 8a1f490b8a62..207edd20dd89 100755
--- a/scripts/run-flake8
+++ b/scripts/run-flake8
@@ -14,7 +14,6 @@ IGNORE_LIST=''
 IGNORE_LIST="$IGNORE_LIST,W191" # indentation contains tabs
 
 IGNORE_LIST="$IGNORE_LIST,E101" # indentation contains mixed spaces and tabs
-IGNORE_LIST="$IGNORE_LIST,E703" # statement ends with a semicolon
 IGNORE_LIST="$IGNORE_LIST,E711" # comparison to None should be 'if cond is not None:'
 IGNORE_LIST="$IGNORE_LIST,E712" # comparison to False should be 'if cond is False:' or 'if not cond:'
 IGNORE_LIST="$IGNORE_LIST,E722" # do not use bare 'except'
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 3/3] python: remove semicolon from end of lines
  2018-08-19 18:49 ` [PATCH 3/3] python: remove semicolon from end of lines Nicolas Iooss
@ 2018-08-20 21:51   ` William Roberts
  2018-08-22  5:59     ` Nicolas Iooss
  0 siblings, 1 reply; 5+ messages in thread
From: William Roberts @ 2018-08-20 21:51 UTC (permalink / raw)
  To: Nicolas Iooss; +Cc: selinux

[-- Attachment #1: Type: text/plain, Size: 4091 bytes --]

Ack on these as well

On Sun, Aug 19, 2018 at 11:49 AM, Nicolas Iooss <nicolas.iooss@m4x.org>
wrote:

> Python does not need to end a statement with a semicolon. Doing this
> gets reported by linters such as flake8 ("E703 statement ends with a
> semicolon").
>
> Remove such semicolons in the code and enable this warning in
> scripts/run-flake8.
>
> Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
> ---
>  python/sepolgen/src/sepolgen/audit.py | 2 +-
>  python/sepolgen/src/sepolgen/yacc.py  | 8 ++++----
>  python/sepolicy/sepolicy/manpage.py   | 2 +-
>  scripts/run-flake8                    | 1 -
>  4 files changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/python/sepolgen/src/sepolgen/audit.py b/python/sepolgen/src/
> sepolgen/audit.py
> index daed58ce9643..4adb851f3e93 100644
> --- a/python/sepolgen/src/sepolgen/audit.py
> +++ b/python/sepolgen/src/sepolgen/audit.py
> @@ -258,7 +258,7 @@ class AVCMessage(AuditMessage):
>          if (scontext, tcontext, self.tclass, access_tuple) in
> avcdict.keys():
>              self.type, self.data = avcdict[(scontext, tcontext,
> self.tclass, access_tuple)]
>          else:
> -            self.type, self.data = audit2why.analyze(scontext, tcontext,
> self.tclass, self.accesses);
> +            self.type, self.data = audit2why.analyze(scontext, tcontext,
> self.tclass, self.accesses)
>              if self.type == audit2why.NOPOLICY:
>                  self.type = audit2why.TERULE
>              if self.type == audit2why.BADTCON:
> diff --git a/python/sepolgen/src/sepolgen/yacc.py b/python/sepolgen/src/
> sepolgen/yacc.py
> index f00635469af1..afef174849f2 100644
> --- a/python/sepolgen/src/sepolgen/yacc.py
> +++ b/python/sepolgen/src/sepolgen/yacc.py
> @@ -1864,10 +1864,10 @@ del _lr_action_items
>  """)
>
>          else:
> -            f.write("\n_lr_action = { ");
> +            f.write("\n_lr_action = { ")
>              for k,v in _lr_action.items():
>                  f.write("(%r,%r):%r," % (k[0],k[1],v))
> -            f.write("}\n");
> +            f.write("}\n")
>
>          if smaller:
>              # Factor out names to try and make smaller
> @@ -1901,10 +1901,10 @@ for _k, _v in _lr_goto_items.items():
>  del _lr_goto_items
>  """)
>          else:
> -            f.write("\n_lr_goto = { ");
> +            f.write("\n_lr_goto = { ")
>              for k,v in _lr_goto.items():
>                  f.write("(%r,%r):%r," % (k[0],k[1],v))
> -            f.write("}\n");
> +            f.write("}\n")
>
>          # Write production table
>          f.write("_lr_productions = [\n")
> diff --git a/python/sepolicy/sepolicy/manpage.py
> b/python/sepolicy/sepolicy/manpage.py
> index cb211ba083ca..cfcb7c3932d7 100755
> --- a/python/sepolicy/sepolicy/manpage.py
> +++ b/python/sepolicy/sepolicy/manpage.py
> @@ -539,7 +539,7 @@ class ManPage:
>                      self.fd = fd
>                      self.man_page_path = man_page_path
>              except KeyError:
> -                continue;
> +                continue
>              self.attributes[domain_type] = next(sepolicy.info(sepolicy.TYPE,
> ("%s") % domain_type))["attributes"]
>
>          self._header()
> diff --git a/scripts/run-flake8 b/scripts/run-flake8
> index 8a1f490b8a62..207edd20dd89 100755
> --- a/scripts/run-flake8
> +++ b/scripts/run-flake8
> @@ -14,7 +14,6 @@ IGNORE_LIST=''
>  IGNORE_LIST="$IGNORE_LIST,W191" # indentation contains tabs
>
>  IGNORE_LIST="$IGNORE_LIST,E101" # indentation contains mixed spaces and
> tabs
> -IGNORE_LIST="$IGNORE_LIST,E703" # statement ends with a semicolon
>  IGNORE_LIST="$IGNORE_LIST,E711" # comparison to None should be 'if cond
> is not None:'
>  IGNORE_LIST="$IGNORE_LIST,E712" # comparison to False should be 'if cond
> is False:' or 'if not cond:'
>  IGNORE_LIST="$IGNORE_LIST,E722" # do not use bare 'except'
> --
> 2.18.0
>
> _______________________________________________
> Selinux mailing list
> Selinux@tycho.nsa.gov
> To unsubscribe, send email to Selinux-leave@tycho.nsa.gov.
> To get help, send an email containing "help" to
> Selinux-request@tycho.nsa.gov.
>

[-- Attachment #2: Type: text/html, Size: 5631 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 3/3] python: remove semicolon from end of lines
  2018-08-20 21:51   ` William Roberts
@ 2018-08-22  5:59     ` Nicolas Iooss
  0 siblings, 0 replies; 5+ messages in thread
From: Nicolas Iooss @ 2018-08-22  5:59 UTC (permalink / raw)
  To: William Roberts; +Cc: selinux

On Mon, Aug 20, 2018 at 11:51 PM William Roberts
<bill.c.roberts@gmail.com> wrote:
>
> Ack on these as well

Thanks, I applied these patches and the previous ones I sent.

Nicolas

>
> On Sun, Aug 19, 2018 at 11:49 AM, Nicolas Iooss <nicolas.iooss@m4x.org> wrote:
>>
>> Python does not need to end a statement with a semicolon. Doing this
>> gets reported by linters such as flake8 ("E703 statement ends with a
>> semicolon").
>>
>> Remove such semicolons in the code and enable this warning in
>> scripts/run-flake8.
>>
>> Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
>> ---
>>  python/sepolgen/src/sepolgen/audit.py | 2 +-
>>  python/sepolgen/src/sepolgen/yacc.py  | 8 ++++----
>>  python/sepolicy/sepolicy/manpage.py   | 2 +-
>>  scripts/run-flake8                    | 1 -
>>  4 files changed, 6 insertions(+), 7 deletions(-)
>>
>> diff --git a/python/sepolgen/src/sepolgen/audit.py b/python/sepolgen/src/sepolgen/audit.py
>> index daed58ce9643..4adb851f3e93 100644
>> --- a/python/sepolgen/src/sepolgen/audit.py
>> +++ b/python/sepolgen/src/sepolgen/audit.py
>> @@ -258,7 +258,7 @@ class AVCMessage(AuditMessage):
>>          if (scontext, tcontext, self.tclass, access_tuple) in avcdict.keys():
>>              self.type, self.data = avcdict[(scontext, tcontext, self.tclass, access_tuple)]
>>          else:
>> -            self.type, self.data = audit2why.analyze(scontext, tcontext, self.tclass, self.accesses);
>> +            self.type, self.data = audit2why.analyze(scontext, tcontext, self.tclass, self.accesses)
>>              if self.type == audit2why.NOPOLICY:
>>                  self.type = audit2why.TERULE
>>              if self.type == audit2why.BADTCON:
>> diff --git a/python/sepolgen/src/sepolgen/yacc.py b/python/sepolgen/src/sepolgen/yacc.py
>> index f00635469af1..afef174849f2 100644
>> --- a/python/sepolgen/src/sepolgen/yacc.py
>> +++ b/python/sepolgen/src/sepolgen/yacc.py
>> @@ -1864,10 +1864,10 @@ del _lr_action_items
>>  """)
>>
>>          else:
>> -            f.write("\n_lr_action = { ");
>> +            f.write("\n_lr_action = { ")
>>              for k,v in _lr_action.items():
>>                  f.write("(%r,%r):%r," % (k[0],k[1],v))
>> -            f.write("}\n");
>> +            f.write("}\n")
>>
>>          if smaller:
>>              # Factor out names to try and make smaller
>> @@ -1901,10 +1901,10 @@ for _k, _v in _lr_goto_items.items():
>>  del _lr_goto_items
>>  """)
>>          else:
>> -            f.write("\n_lr_goto = { ");
>> +            f.write("\n_lr_goto = { ")
>>              for k,v in _lr_goto.items():
>>                  f.write("(%r,%r):%r," % (k[0],k[1],v))
>> -            f.write("}\n");
>> +            f.write("}\n")
>>
>>          # Write production table
>>          f.write("_lr_productions = [\n")
>> diff --git a/python/sepolicy/sepolicy/manpage.py b/python/sepolicy/sepolicy/manpage.py
>> index cb211ba083ca..cfcb7c3932d7 100755
>> --- a/python/sepolicy/sepolicy/manpage.py
>> +++ b/python/sepolicy/sepolicy/manpage.py
>> @@ -539,7 +539,7 @@ class ManPage:
>>                      self.fd = fd
>>                      self.man_page_path = man_page_path
>>              except KeyError:
>> -                continue;
>> +                continue
>>              self.attributes[domain_type] = next(sepolicy.info(sepolicy.TYPE, ("%s") % domain_type))["attributes"]
>>
>>          self._header()
>> diff --git a/scripts/run-flake8 b/scripts/run-flake8
>> index 8a1f490b8a62..207edd20dd89 100755
>> --- a/scripts/run-flake8
>> +++ b/scripts/run-flake8
>> @@ -14,7 +14,6 @@ IGNORE_LIST=''
>>  IGNORE_LIST="$IGNORE_LIST,W191" # indentation contains tabs
>>
>>  IGNORE_LIST="$IGNORE_LIST,E101" # indentation contains mixed spaces and tabs
>> -IGNORE_LIST="$IGNORE_LIST,E703" # statement ends with a semicolon
>>  IGNORE_LIST="$IGNORE_LIST,E711" # comparison to None should be 'if cond is not None:'
>>  IGNORE_LIST="$IGNORE_LIST,E712" # comparison to False should be 'if cond is False:' or 'if not cond:'
>>  IGNORE_LIST="$IGNORE_LIST,E722" # do not use bare 'except'
>> --
>> 2.18.0
>>
>> _______________________________________________
>> Selinux mailing list
>> Selinux@tycho.nsa.gov
>> To unsubscribe, send email to Selinux-leave@tycho.nsa.gov.
>> To get help, send an email containing "help" to Selinux-request@tycho.nsa.gov.
>
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-08-22  6:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-19 18:48 [PATCH 1/3] libselinux: add a const to suppress a build warning with Python 3.7 Nicolas Iooss
2018-08-19 18:49 ` [PATCH 2/3] Travis-CI: upgrade to Ubuntu 16.04 LTS Xenial Xerus Nicolas Iooss
2018-08-19 18:49 ` [PATCH 3/3] python: remove semicolon from end of lines Nicolas Iooss
2018-08-20 21:51   ` William Roberts
2018-08-22  5:59     ` Nicolas Iooss

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.