Skip to content

Commit

Permalink
Fix random issues detected by Coverity tool
Browse files Browse the repository at this point in the history
This commit doesn't fix any real bugs, but only removes some dead code.

Signed-off-by: jkr0103 <jitender.kumar@intel.com>
  • Loading branch information
jkr0103 authored and dimakuv committed Oct 27, 2023
1 parent 53a0178 commit 653731a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
7 changes: 3 additions & 4 deletions common/src/protected_files/protected_files.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ static void ipf_init_root_mht(file_node_t* mht) {
static bool ipf_update_all_data_and_mht_nodes(pf_context_t* pf) {
bool ret = false;
file_node_t** mht_array = NULL;
file_node_t* file_mht_node;
pf_status_t status;
void* data = lruc_get_first(pf->cache);

Expand Down Expand Up @@ -232,8 +231,8 @@ static bool ipf_update_all_data_and_mht_nodes(pf_context_t* pf) {
goto out;
}

file_mht_node = data_node->parent;
#ifdef DEBUG
file_node_t* file_mht_node = data_node->parent;
// this loop should do nothing, add it here just to be safe
while (file_mht_node->node_number != 0) {
assert(file_mht_node->need_writing == true);
Expand Down Expand Up @@ -268,7 +267,7 @@ static bool ipf_update_all_data_and_mht_nodes(pf_context_t* pf) {
uint64_t dirty_idx = 0;
while (data != NULL) {
if (((file_node_t*)data)->type == FILE_MHT_NODE_TYPE) {
file_mht_node = (file_node_t*)data;
file_node_t* file_mht_node = (file_node_t*)data;

if (file_mht_node->need_writing)
mht_array[dirty_idx++] = file_mht_node;
Expand All @@ -282,7 +281,7 @@ static bool ipf_update_all_data_and_mht_nodes(pf_context_t* pf) {

// update the gmacs in the parents from last node to first (bottom layers first)
for (dirty_idx = dirty_count; dirty_idx > 0; dirty_idx--) {
file_mht_node = mht_array[dirty_idx - 1];
file_node_t* file_mht_node = mht_array[dirty_idx - 1];

gcm_crypto_data_t* gcm_crypto_data =
&file_mht_node->parent->decrypted.mht
Expand Down
4 changes: 2 additions & 2 deletions libos/src/sys/libos_poll.c
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ static long do_select(int nfds, struct linux_fd_set* read_set, struct linux_fd_s

long libos_syscall_select(int nfds, struct linux_fd_set* read_set, struct linux_fd_set* write_set,
struct linux_fd_set* except_set, struct __kernel_timeval* tv) {
if (nfds < 0 || (uint64_t)nfds > get_rlimit_cur(RLIMIT_NOFILE) || nfds > INT_MAX)
if (nfds < 0 || (uint64_t)nfds > get_rlimit_cur(RLIMIT_NOFILE))
return -EINVAL;

/* Each of `read_set`, `write_set` and `except_set` is an array of linux_fd_set items; each
Expand Down Expand Up @@ -427,7 +427,7 @@ struct sigset_argpack {
long libos_syscall_pselect6(int nfds, struct linux_fd_set* read_set, struct linux_fd_set* write_set,
struct linux_fd_set* except_set, struct __kernel_timespec* tsp,
void* _sigmask_argpack) {
if (nfds < 0 || (uint64_t)nfds > get_rlimit_cur(RLIMIT_NOFILE) || nfds > INT_MAX)
if (nfds < 0 || (uint64_t)nfds > get_rlimit_cur(RLIMIT_NOFILE))
return -EINVAL;

/* for explanation on calculations below, see libos_syscall_select() */
Expand Down
4 changes: 0 additions & 4 deletions pal/src/host/linux/pal_streams.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,6 @@ int _PalSendHandle(PAL_HANDLE target_process, PAL_HANDLE cargo) {
message_hdr.msg_iovlen = 1;

ret = DO_SYSCALL(sendmsg, fd, &message_hdr, 0);
if (ret < 0) {
free(hdl_data);
return unix_to_pal_error(ret);
}

free(hdl_data);
return ret < 0 ? unix_to_pal_error(ret) : 0;
Expand Down
6 changes: 5 additions & 1 deletion python/graminelibos/gen_jinja_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,11 @@ def add_globals_misc(env):
env.globals['ldd'] = ldd

def make_env():
env = jinja2.Environment(undefined=jinja2.StrictUndefined, keep_trailing_newline=True)

# Jinja's autoescape feature escapes HTML sequences but we're rendering TOML, hence explicitly
# setting autoescape to False
env = jinja2.Environment(undefined=jinja2.StrictUndefined, keep_trailing_newline=True,
autoescape=False)
add_globals_from_gramine(env)
add_globals_from_python(env)
add_globals_misc(env)
Expand Down

0 comments on commit 653731a

Please sign in to comment.