Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xattr-util.c compiler warnings, with fixes #12

Open
JamesBucanek opened this issue Dec 29, 2012 · 0 comments
Open

xattr-util.c compiler warnings, with fixes #12

JamesBucanek opened this issue Dec 29, 2012 · 0 comments

Comments

@JamesBucanek
Copy link

I just downloaded and built Backup-Bouncer with the latest LLVM compiler (Xcode 4.5.2). make throws several compiler warnings, which should be addressed:

marchhare:~ james$ cd /Users/james/Development/software/Backup\ Bouncer/backup-bouncer-0.2.0\ 2
marchhare:backup-bouncer-0.2.0 2 james$ make
cd util && make
cc -Wall xattr-util.c -o xattr-util
xattr-util.c:17:23: warning: comparison of unsigned expression >= 0 is always true [-Wtautological-compare]
if (read_size >= 0) {
~~~~~~~~~ ^ ~
xattr-util.c:70:18: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
if (size < 0) {
~~~~ ^ ~
xattr-util.c:76:18: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
if (size < 0) {
~~~~ ^ ~
xattr-util.c:96:18: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
if (size < 0) {
~~~~ ^ ~
xattr-util.c:102:18: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
if (size < 0) {
~~~~ ^ ~
xattr-util.c:107:15: warning: unused variable 'value' [-Wunused-variable]
void *value;
^
6 warnings generated.

Specifically, there are a couple of variables named 'size' used to store the result of getxattr() and listxattr(). The problem is that they are size_t vars, but getxattr() and listxattr() return ssize_t. The subsequent tests to see if size if negative are meaningless.

Finally, there's an unused variable.

Here's the fixes that correct the problems and eliminate the compiler warnings:

16c16
< size_t read_size = getxattr(file, name, result, size, 0, options);


    ssize_t read_size = getxattr(file, name, result, size, 0, options);

66c66
< size_t size = listxattr(argv[2], NULL, 0, options);

    ssize_t size = listxattr(argv[2], NULL, 0, options);

92c92
< size_t size = listxattr(argv[2], NULL, 0, options);

    ssize_t size = listxattr(argv[2], NULL, 0, options);

107c107
< void *value;

    //void *value;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant