Skip to content

Commit

Permalink
Fix other mode related if
Browse files Browse the repository at this point in the history
  • Loading branch information
Luca Marturana committed Jan 18, 2017
1 parent df8abb2 commit a428209
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
40 changes: 20 additions & 20 deletions userspace/libscap/scap.c
Original file line number Diff line number Diff line change
Expand Up @@ -924,9 +924,9 @@ int32_t scap_stop_capture(scap_t* handle)
//
// Not supported for files
//
if(handle->m_file)
if(handle->m_mode != SCAP_MODE_LIVE)
{
snprintf(handle->m_lasterr, SCAP_LASTERR_SIZE, "cannot stop offline captures");
snprintf(handle->m_lasterr, SCAP_LASTERR_SIZE, "cannot stop not live captures");
ASSERT(false);
return SCAP_FAILURE;
}
Expand Down Expand Up @@ -962,9 +962,9 @@ int32_t scap_start_capture(scap_t* handle)
//
// Not supported for files
//
if(handle->m_file)
if(handle->m_mode != SCAP_MODE_LIVE)
{
snprintf(handle->m_lasterr, SCAP_LASTERR_SIZE, "cannot start offline captures");
snprintf(handle->m_lasterr, SCAP_LASTERR_SIZE, "cannot start capture on this scap mode");
ASSERT(false);
return SCAP_FAILURE;
}
Expand Down Expand Up @@ -992,9 +992,9 @@ static int32_t scap_set_dropping_mode(scap_t* handle, int request, uint32_t samp
//
// Not supported for files
//
if(handle->m_file)
if(handle->m_mode != SCAP_MODE_LIVE)
{
snprintf(handle->m_lasterr, SCAP_LASTERR_SIZE, "dropping mode not supported on offline captures");
snprintf(handle->m_lasterr, SCAP_LASTERR_SIZE, "dropping mode not supported on this scap mode");
ASSERT(false);
return SCAP_FAILURE;
}
Expand All @@ -1019,9 +1019,9 @@ int32_t scap_enable_tracers_capture(scap_t* handle)
//
// Not supported for files
//
if(handle->m_file)
if(handle->m_mode != SCAP_MODE_LIVE)
{
snprintf(handle->m_lasterr, SCAP_LASTERR_SIZE, "scap_set_inode_of_dev_null not supported on offline captures");
snprintf(handle->m_lasterr, SCAP_LASTERR_SIZE, "scap_set_inode_of_dev_null not supported on this scap mode");
ASSERT(false);
return SCAP_FAILURE;
}
Expand Down Expand Up @@ -1099,9 +1099,9 @@ int32_t scap_set_snaplen(scap_t* handle, uint32_t snaplen)
//
// Not supported on files
//
if(handle->m_file)
if(handle->m_mode != SCAP_MODE_LIVE)
{
snprintf(handle->m_lasterr, SCAP_LASTERR_SIZE, "setting snaplen not supported on offline captures");
snprintf(handle->m_lasterr, SCAP_LASTERR_SIZE, "setting snaplen not supported on this scap mode");
return SCAP_FAILURE;
}

Expand Down Expand Up @@ -1143,9 +1143,9 @@ int32_t scap_set_snaplen(scap_t* handle, uint32_t snaplen)

int64_t scap_get_readfile_offset(scap_t* handle)
{
if(handle->m_file == NULL)
if(handle->m_mode != SCAP_MODE_CAPTURE)
{
snprintf(handle->m_lasterr, SCAP_LASTERR_SIZE, "scap_get_readfile_offset only works on trace files");
snprintf(handle->m_lasterr, SCAP_LASTERR_SIZE, "scap_get_readfile_offset only works on captures");
return -1;
}

Expand All @@ -1157,9 +1157,9 @@ static int32_t scap_handle_eventmask(scap_t* handle, uint32_t op, uint32_t event
//
// Not supported on files
//
if(handle->m_file)
if(handle->m_mode != SCAP_MODE_LIVE)
{
snprintf(handle->m_lasterr, SCAP_LASTERR_SIZE, "manipulating eventmasks not supported on offline captures");
snprintf(handle->m_lasterr, SCAP_LASTERR_SIZE, "manipulating eventmasks not supported on this scap mode");
return SCAP_FAILURE;
}

Expand Down Expand Up @@ -1250,9 +1250,9 @@ int32_t scap_enable_dynamic_snaplen(scap_t* handle)
//
// Not supported on files
//
if(handle->m_file)
if(handle->m_mode != SCAP_MODE_LIVE)
{
snprintf(handle->m_lasterr, SCAP_LASTERR_SIZE, "setting snaplen not supported on offline captures");
snprintf(handle->m_lasterr, SCAP_LASTERR_SIZE, "setting snaplen not supported on this scap mode");
return SCAP_FAILURE;
}

Expand Down Expand Up @@ -1280,9 +1280,9 @@ int32_t scap_disable_dynamic_snaplen(scap_t* handle)
//
// Not supported on files
//
if(handle->m_file)
if(handle->m_mode != SCAP_MODE_LIVE)
{
snprintf(handle->m_lasterr, SCAP_LASTERR_SIZE, "setting snaplen not supported on offline captures");
snprintf(handle->m_lasterr, SCAP_LASTERR_SIZE, "setting snaplen not supported on this scap mode");
return SCAP_FAILURE;
}

Expand Down Expand Up @@ -1352,9 +1352,9 @@ struct ppm_proclist_info* scap_get_threadlist_from_driver(scap_t* handle)
//
// Not supported on files
//
if(handle->m_file)
if(handle->m_mode != SCAP_MODE_LIVE)
{
snprintf(handle->m_lasterr, SCAP_LASTERR_SIZE, "scap_get_threadlist_from_driver not supported on offline captures");
snprintf(handle->m_lasterr, SCAP_LASTERR_SIZE, "scap_get_threadlist_from_driver not supported on this scap mode");
return NULL;
}

Expand Down
4 changes: 2 additions & 2 deletions userspace/libscap/scap_procs.c
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,7 @@ struct scap_threadinfo* scap_proc_get(scap_t* handle, int64_t tid, bool scan_soc
//
// No /proc parsing for offline captures
//
if(handle->m_file)
if(handle->m_mode == SCAP_MODE_CAPTURE)
{
return NULL;
}
Expand Down Expand Up @@ -960,7 +960,7 @@ bool scap_is_thread_alive(scap_t* handle, int64_t pid, int64_t tid, const char*
//
// No /proc parsing for offline captures
//
if(handle->m_file)
if(handle->m_mode == SCAP_MODE_CAPTURE)
{
return false;
}
Expand Down

0 comments on commit a428209

Please sign in to comment.