Skip to content

Commit

Permalink
Input validation
Browse files Browse the repository at this point in the history
  • Loading branch information
qiluo-msft committed Apr 28, 2020
1 parent 6a10c22 commit ffdf5d9
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions orchagent/bulker.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,13 @@ class EntityBulker
_In_ uint32_t attr_count,
_In_ const sai_attribute_t *attr_list)
{
assert(object_status);
if (!object_status) throw std::invalid_argument("object_status is null");
assert(entry);
if (!entry) throw std::invalid_argument("entry is null");
assert(attr_list);
if (!attr_list) throw std::invalid_argument("attr_list is null");

auto rc = creating_entries.emplace(std::piecewise_construct,
std::forward_as_tuple(*entry),
std::forward_as_tuple());
Expand All @@ -192,6 +199,8 @@ class EntityBulker
_Out_ sai_status_t *object_status,
_In_ const Te *entry)
{
assert(object_status);
if (!object_status) throw std::invalid_argument("object_status is null");
assert(entry);
if (!entry) throw std::invalid_argument("entry is null");

Expand Down Expand Up @@ -235,6 +244,13 @@ class EntityBulker
_In_ const Te *entry,
_In_ const sai_attribute_t *attr)
{
assert(object_status);
if (!object_status) throw std::invalid_argument("object_status is null");
assert(entry);
if (!entry) throw std::invalid_argument("entry is null");
assert(attr);
if (!attr) throw std::invalid_argument("attr is null");

// Insert or find the key (entry)
auto& attrmap = setting_entries.emplace(std::piecewise_construct,
std::forward_as_tuple(*entry),
Expand Down Expand Up @@ -465,6 +481,11 @@ class ObjectBulker
_In_ uint32_t attr_count,
_In_ const sai_attribute_t *attr_list)
{
assert(object_id);
if (!object_id) throw std::invalid_argument("object_id is null");
assert(attr_list);
if (!attr_list) throw std::invalid_argument("attr_list is null");

creating_entries.emplace_back(std::piecewise_construct, std::forward_as_tuple(object_id), std::forward_as_tuple(attr_list, attr_list + attr_count));

auto& last_attrs = std::get<1>(creating_entries.back());
Expand All @@ -478,6 +499,8 @@ class ObjectBulker
_Out_ sai_status_t *object_status,
_In_ sai_object_id_t object_id)
{
assert(object_status);
if (!object_status) throw std::invalid_argument("object_status is null");
assert(object_id != SAI_NULL_OBJECT_ID);
if (object_id == SAI_NULL_OBJECT_ID) throw std::invalid_argument("object_id is null");

Expand Down

0 comments on commit ffdf5d9

Please sign in to comment.