Skip to content

build: remove warnings during build#948

Merged
arogge merged 51 commits intomasterfrom
dev/pstorz/master/reduce-warnings
Nov 2, 2021
Merged

build: remove warnings during build#948
arogge merged 51 commits intomasterfrom
dev/pstorz/master/reduce-warnings

Conversation

@pstorz
Copy link
Member

@pstorz pstorz commented Oct 1, 2021

Thank you for contributing to the Bareos Project!

Please check

  • Short description and the purpose of this PR is present above this paragraph
  • Your name is present in the AUTHORS file (optional)

If you have any questions or problems, please give a comment in the PR.

Helpful documentation and best practices

Checklist for the reviewer of the PR (will be processed by the Bareos team)

General
  • PR name is meaningful
  • Purpose of the PR is understood
  • Commit descriptions are understandable and well formatted
Source code quality
  • Source code changes are understandable
  • Variable and function names are meaningful
  • Code comments are correct (logically and spelling)
  • bareos-check-sources --since-merge does not report any problems
  • git status should not report modifications in the source tree after building and testing

@pstorz pstorz marked this pull request as draft October 1, 2021 16:07
Copy link
Member

@arogge arogge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still needs some work, some of the read() and write() calls are still not checked thoroughly.
But good progress anyway!

while (items && list_index < items_list_size) {
name = (char*)items->list[list_index];
list_index++;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lines following this do a malloc(), followed by a strcpy() and then return the allocated string.
Isn't that exactly what strdup() does?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly

Comment on lines +60 to +75
// macros that check for the return value of read() and write()
// to avoid warnings about unused results.
#define READ(FD, BUF, COUNT) \
if (read(FD, BUF, COUNT) < 0) { \
BErrNo be; \
Emsg1(M_FATAL, 0, _("read failed: %s\n"), be.bstrerror()); \
}

#define WRITE(FD, BUF, COUNT) \
if (write(FD, BUF, COUNT) < 0) { \
BErrNo be; \
Emsg1(M_FATAL, 0, _("write failed: %s\n"), be.bstrerror()); \
}


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is a lot easier to do have inline functions than a macro.
Otherwise you'd need to wrap into do { .. } while(0); so it won't behave strangely.

}

children = json_object_object_get(obj, "children");
json_object_object_get_ex(obj, "children", &children);
Copy link
Member

@arogge arogge Oct 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return code is bool and should probably be checked. The docs doesn't state what children will be set to on error, so we should probably assume it can be undefined and not rely on comparing with NULL only.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, will fix that

int status;
int status = 0;

# if (OPENSSL_VERSION_NUMBER <= 0x10000000L)
Copy link
Member

@arogge arogge Oct 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You cannot remove that for OpenSSL 1.0.0. Otherwise locking won't work and threading will break.
However, you can probably remove it for OpenSSL 1.1.0, but please make really sure none of the removed calls is required (we have broken that in the past already).

install(TARGETS python-dir DESTINATION ${plugindir})
target_link_libraries(python-dir ${Python2_LIBRARIES} bareos)
target_include_directories(python-dir PUBLIC SYSTEM ${Python2_INCLUDE_DIRS})
target_include_directories(python-dir SYSTEM PUBLIC ${Python2_INCLUDE_DIRS})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while this will silence the warning for strict-aliasing, we should probably also set -fno-strict-aliasing as a compile option so the compiler will not generate broken code.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

@pstorz pstorz force-pushed the dev/pstorz/master/reduce-warnings branch 2 times, most recently from 4ac2d5a to a3c7bd0 Compare October 8, 2021 13:26
*af = AF_INET6;
} else {
strncpy(new_host, host, host_len);
strncpy(new_host, host, strlen(new_host));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if new_host points to newly allocated memory, that has been zero initialized, strlen(new_host) will evalutate to 0, which will lead to not copying host at all.

Dmsg1(000, "Write hdr error: ERR=%s\n", be.bstrerror());
goto bail_out;
}
!= sizeof(crypto_cache_hdr)) {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that doesn't look right.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still not right.

Comment on lines +2829 to 2831
_("[file_size=n(GB)|nb_file=3|skip_zero|skip_random|skip_raw|skip_block]"
" "
"report drive speed")},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
_("[file_size=n(GB)|nb_file=3|skip_zero|skip_random|skip_raw|skip_block]"
" "
"report drive speed")},
_("[file_size=n(GB)|nb_file=3|skip_zero|skip_random|skip_raw|skip_block]"
" report drive speed")},

@arogge arogge force-pushed the dev/pstorz/master/reduce-warnings branch from 1ddd4e1 to 01390cd Compare October 11, 2021 13:23
@arogge
Copy link
Member

arogge commented Oct 11, 2021

The old Debian 9.0 and Univention 4.4 systems complain about unused functions and the unknown attribute [[maybe-unused]].

@arogge
Copy link
Member

arogge commented Oct 11, 2021

Then we should probably disable droplet in i386, as it is definitely broken (or we would have to fix a lot of format-strings)

@arogge arogge force-pushed the dev/pstorz/master/reduce-warnings branch from 01390cd to 8592330 Compare October 11, 2021 15:47

static void InitSignalHandler()
{
#if !HAVE_WIN32
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#if !HAVE_WIN32
#if !defined(HAVE_WIN32)

@arogge arogge force-pushed the dev/pstorz/master/reduce-warnings branch 3 times, most recently from a2c16af to 84ce4d0 Compare October 12, 2021 20:31
@pstorz pstorz force-pushed the dev/pstorz/master/reduce-warnings branch 3 times, most recently from 838ec7a to 3f3c219 Compare October 19, 2021 14:57
@pstorz pstorz changed the title build: reduce warnings during build build: remove warnings during build Oct 19, 2021
@pstorz pstorz marked this pull request as ready for review October 19, 2021 19:01
Dmsg1(000, "Write hdr error: ERR=%s\n", be.bstrerror());
goto bail_out;
}
!= sizeof(crypto_cache_hdr)) {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still not right.

@pstorz pstorz requested a review from arogge October 27, 2021 14:37
@arogge arogge force-pushed the dev/pstorz/master/reduce-warnings branch 2 times, most recently from 1e365c7 to d893c06 Compare November 2, 2021 09:30
arogge and others added 27 commits November 2, 2021 11:59
Apparently Solaris can produce strings up to 299 bytes for this, so we
increase the size of the buffer to 300 bytes.
LMDB utilizes some kind of old-style variable-length-array. This leads
to stringop-overflow warnings, which we can ignore as the out-of-bounds
access is intentional (and not really out-of-bounds).
This patch removes the openssl thread callbacks when building with
OpenSSL 1.1.0 or newer. However, references to the callbacks are kept,
so if any of them was required, compiling would fail.
this is a no-op anyway and will yield a compiler warning, so we disable
it.
This patch replaces "%F %T" with the equivalent (and more portable) long
variant "%Y-%m-%d %H:%M:%S", so that Windows build will show progress,
too.
When initializing BareosWinFilePacket* we now use placement new so the
struct values are nicely initialized by our constructor instead of
forced zero initialization like before.
Previously for win32 'I' was used, but this is not required anymore and
will produce a warning on mingw32.
Previously LINK_LIBRARIES for sd_reservation was overspecified which
lead to an issue with ODR (symbols from SD and Dir could have been
used).
The macro PLATFORM is already used in pyconfig.h on Windows builds, so
we rename our macro to BAREOS_PLATFORM to avoid clashing.
The configuration parser had set the undocumented and unused environment
variable BAREOS_CFGDIR, which could potentially have been used in
scripts and programs generating configuration snippets. However, as this
was never documented and is not used by Bareos itself, we remove it and
with it the need for setenv() and/or putenv().
Python should autodetect 32-bit and 64-bit Windows, but this is broken
when building with GCC[1].
The previous workaround we had in place defined MS_WIN32 or MS_WIN64
depending on what we're building. As MS_WIN32 is always defined, we
should only define MS_WIN64 in case we're building 64-bit Windows.

[1] https://bugs.python.org/issue4709
As we currently have no warning left, we reduce the quality gates to be
strict.
As droplet is now part of the bareos repo.
As we currently have no warning left, we reduce the quality gates to be
strict.
@arogge arogge force-pushed the dev/pstorz/master/reduce-warnings branch from d893c06 to 910adfb Compare November 2, 2021 11:01
@arogge arogge merged commit 4b078a4 into master Nov 2, 2021
@arogge arogge deleted the dev/pstorz/master/reduce-warnings branch November 2, 2021 11:01
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

Successfully merging this pull request may close these issues.

2 participants