mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 06:15:47 +00:00
vlog: fix clang warnings
Make sure clang does not complain about accessing ovs_log_file outside of log_file_mutex protection. Signed-off-by: Andy Zhou <azhou@nicira.com>
This commit is contained in:
11
lib/vlog.c
11
lib/vlog.c
@@ -105,7 +105,7 @@ DEFINE_STATIC_PER_THREAD_DATA(unsigned int, msg_num, 0);
|
|||||||
* All of the following is protected by 'log_file_mutex', which nests inside
|
* All of the following is protected by 'log_file_mutex', which nests inside
|
||||||
* pattern_rwlock. */
|
* pattern_rwlock. */
|
||||||
static struct ovs_mutex log_file_mutex = OVS_MUTEX_INITIALIZER;
|
static struct ovs_mutex log_file_mutex = OVS_MUTEX_INITIALIZER;
|
||||||
static char *log_file_name = NULL OVS_GUARDED_BY(log_file_mutex);
|
static char *log_file_name OVS_GUARDED_BY(log_file_mutex) = NULL;
|
||||||
static int log_fd OVS_GUARDED_BY(log_file_mutex) = -1;
|
static int log_fd OVS_GUARDED_BY(log_file_mutex) = -1;
|
||||||
static struct async_append *log_writer OVS_GUARDED_BY(log_file_mutex);
|
static struct async_append *log_writer OVS_GUARDED_BY(log_file_mutex);
|
||||||
static bool log_async OVS_GUARDED_BY(log_file_mutex);
|
static bool log_async OVS_GUARDED_BY(log_file_mutex);
|
||||||
@@ -438,18 +438,15 @@ vlog_reopen_log_file(void)
|
|||||||
void
|
void
|
||||||
vlog_change_owner_unix(uid_t user, gid_t group)
|
vlog_change_owner_unix(uid_t user, gid_t group)
|
||||||
{
|
{
|
||||||
if (!log_file_name) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ovs_mutex_lock(&log_file_mutex);
|
ovs_mutex_lock(&log_file_mutex);
|
||||||
int error = chown(log_file_name, user, group);
|
int error = log_file_name ? chown(log_file_name, user, group) : 0;
|
||||||
ovs_mutex_unlock(&log_file_mutex);
|
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
VLOG_FATAL("Failed to change %s ownership: %s.",
|
VLOG_FATAL("Failed to change %s ownership: %s.",
|
||||||
log_file_name, ovs_strerror(errno));
|
log_file_name, ovs_strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ovs_mutex_unlock(&log_file_mutex);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user