Merge pull request #7241 from keszybz/clang-warnings

Fixes for various clang warnings
This commit is contained in:
Lennart Poettering 2017-11-02 19:21:10 +01:00 committed by GitHub
commit 6e9834ea0f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 25 additions and 16 deletions

View file

@ -1556,7 +1556,7 @@ int read_line(FILE *f, size_t limit, char **ret) {
}
{
_cleanup_(funlockfilep) FILE *flocked = f;
_unused_ _cleanup_(funlockfilep) FILE *flocked = f;
flockfile(f);
for (;;) {

View file

@ -245,7 +245,6 @@ int ask_string(char **ret, const char *text, ...) {
int reset_terminal_fd(int fd, bool switch_to_text) {
struct termios termios;
_cleanup_free_ char *utf8 = NULL;
int r = 0;
/* Set terminal to some sane defaults */

View file

@ -1177,8 +1177,6 @@ int bus_exec_context_set_transient_property(
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid personality");
if (mode != UNIT_CHECK) {
_cleanup_free_ char *str = NULL;
c->personality = p;
unit_write_drop_in_private_format(u, mode, name, "%s=%s", name, s);
}

View file

@ -56,7 +56,7 @@ static bool arg_root_enabled = true;
static bool arg_root_rw = false;
static int add_cryptsetup(const char *id, const char *what, bool rw, bool require, char **device) {
_cleanup_free_ char *e = NULL, *n = NULL, *p = NULL, *d = NULL, *to = NULL;
_cleanup_free_ char *e = NULL, *n = NULL, *p = NULL, *d = NULL;
_cleanup_fclose_ FILE *f = NULL;
char *ret;
int r;

View file

@ -251,7 +251,7 @@ static void transfer_send_logs(Transfer *t, bool flush) {
n = strndup(t->log_message, e - t->log_message);
/* Skip over NUL and newlines */
while ((e < t->log_message + t->log_message_size) && IN_SET(*e, 0, '\n'))
while (e < t->log_message + t->log_message_size && (*e == 0 || *e == '\n'))
e++;
memmove(t->log_message, e, t->log_message + sizeof(t->log_message) - e);

View file

@ -90,6 +90,10 @@
/* The mmap context to use for the header we pick as one above the last defined typed */
#define CONTEXT_HEADER _OBJECT_TYPE_MAX
#ifdef __clang__
# pragma GCC diagnostic ignored "-Waddress-of-packed-member"
#endif
/* This may be called from a separate thread to prevent blocking the caller for the duration of fsync().
* As a result we use atomic operations on f->offline_state for inter-thread communications with
* journal_file_set_offline() and journal_file_set_online(). */

View file

@ -332,7 +332,7 @@ void server_process_native_message(
const char *label, size_t label_len) {
size_t remaining = buffer_size;
ClientContext *context;
ClientContext *context = NULL;
int r;
assert(s);

View file

@ -228,7 +228,7 @@ int main(int argc, char *argv[]) {
} mode = MODE_BISECT;
Type type = TYPE_LEGACY;
int i, pair[2] = { -1, -1 };
_cleanup_free_ char *name = NULL, *bus_name = NULL, *address = NULL, *server_name = NULL;
_cleanup_free_ char *address = NULL, *server_name = NULL;
_cleanup_close_ int bus_ref = -1;
const char *unique;
cpu_set_t cpuset;

View file

@ -1136,7 +1136,6 @@ void session_restore_vt(Session *s) {
.mode = VT_AUTO,
};
_cleanup_free_ char *utf8 = NULL;
int vt, old_fd;
/* We need to get a fresh handle to the virtual terminal,

View file

@ -3573,7 +3573,8 @@ int link_save(Link *link) {
if (r < 0)
goto fail;
fprintf(f, "%s%s/%hhu/%hhu/%"PRIu32"/%hhu/"USEC_FMT, space ? " " : "", route_str,
fprintf(f, "%s%s/%hhu/%hhu/%"PRIu32"/%"PRIu32"/"USEC_FMT,
space ? " " : "", route_str,
route->dst_prefixlen, route->tos, route->priority, route->table, route->lifetime);
space = true;
}

View file

@ -1142,8 +1142,12 @@ static int manager_save(Manager *m) {
goto fail;
}
fprintf(f, "from=%s%s/%hhu to=%s%s/%hhu tos=%hhu fwmark=%"PRIu32"/%"PRIu32" table=%hhu", space ? " " : "", from_str,
rule->from_prefixlen, space ? " " : "", to_str, rule->to_prefixlen, rule->tos, rule->fwmark, rule->fwmask, rule->table);
fprintf(f, "from=%s%s/%hhu to=%s%s/%hhu tos=%hhu fwmark=%"PRIu32"/%"PRIu32" table=%"PRIu32,
space ? " " : "", from_str, rule->from_prefixlen,
space ? " " : "", to_str, rule->to_prefixlen,
rule->tos,
rule->fwmark, rule->fwmask,
rule->table);
fputc('\n', f);
}

View file

@ -672,7 +672,6 @@ int config_parse_routing_policy_rule_fwmark_mask(
void *userdata) {
_cleanup_routing_policy_rule_free_ RoutingPolicyRule *n = NULL;
_cleanup_free_ char *fwmark = NULL;
Network *network = userdata;
int r;
@ -751,7 +750,7 @@ int config_parse_routing_policy_rule_prefix(
}
static int routing_policy_rule_read_full_file(char *state_file, char **ret) {
_cleanup_free_ char *s = NULL, *p = NULL;
_cleanup_free_ char *s = NULL;
size_t size;
int r;

View file

@ -245,7 +245,6 @@ static int acquire_generator_dirs(
char **generator_early,
char **generator_late) {
_cleanup_(rmdir_and_freep) char *t = NULL;
_cleanup_free_ char *x = NULL, *y = NULL, *z = NULL;
const char *prefix;

View file

@ -704,7 +704,6 @@ static void test_read_line_one_file(FILE *f) {
static void test_read_line(void) {
_cleanup_fclose_ FILE *f = NULL;
_cleanup_free_ char *line = NULL;
f = fmemopen((void*) buffer, sizeof(buffer), "re");
assert_se(f);

View file

@ -104,6 +104,11 @@ static void test_max(void) {
assert_se(CLAMP(CLAMP(0, -10, 10), CLAMP(-5, 10, 20), CLAMP(100, -5, 20)) == 10);
}
#pragma GCC diagnostic push
#ifdef __clang__
# pragma GCC diagnostic ignored "-Waddress-of-packed-member"
#endif
static void test_container_of(void) {
struct mytype {
uint8_t pad1[3];
@ -122,6 +127,8 @@ static void test_container_of(void) {
v1) == &myval);
}
#pragma GCC diagnostic pop
static void test_div_round_up(void) {
int div;