lilydjwg / swapview-rosetta

Print swap usage per process. Implemented in various programming languages
491 stars 108 forks source link

Fix some types in Cython version #167

Closed felixonmars closed 3 years ago

felixonmars commented 3 years ago

The change to filesize()'s argument fixes the following OverflowError:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "swapview.pyx", line 91, in init swapview
    main()
  File "swapview.pyx", line 88, in swapview.main
    t = filesize(sum(x[1] for x in results))
  File "swapview.pyx", line 27, in swapview.filesize
    def filesize(int size):
OverflowError: value too large to convert to int

The declaration of read fixes the following warning:

gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -fno-semantic-interposition -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -fPIC -I/usr/include/python3.9 -c swapview.c -o build/temp.linux-x86_64-3.9/swapview.o
swapview.c: In function ‘__pyx_pf_8swapview_2getSwapFor’:
swapview.c:2261:36: warning: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘long unsigned int’} and ‘long int’ [-Wsign-compare]
 2261 |         __pyx_t_7 = ((__pyx_v_read == -1L) != 0);
      |                                    ^~
lilydjwg commented 3 years ago

Thanks!