ZC API: Add checks for ensuring that regMode and deregMode are valid 37/5137/3
authorNitin Bhat <nbhat4@illinois.edu>
Fri, 26 Apr 2019 19:32:07 +0000 (14:32 -0500)
committerNitin Bhat <nbhat4@illinois.edu>
Tue, 7 May 2019 14:39:31 +0000 (09:39 -0500)
Change-Id: I13bea94d82ac6629ea07f6626d07cdab1fa21d2b

src/ck-core/ckrdma.h

index 8491cd057e33152668f783907e5e8512e339185c..4f639bbddf47923474aaec90e9feb040ca0c1c92 100644 (file)
@@ -84,6 +84,16 @@ class CkNcpyBuffer{
   #pragma GCC diagnostic pop
   #endif
 
+#if CMK_ERROR_CHECKING
+  void checkRegModeIsValid() {
+    if(regMode < CK_BUFFER_REG || regMode > CK_BUFFER_NOREG) CmiAbort("checkRegModeIsValid: Invalid value for regMode!\n");
+  }
+
+  void checkDeregModeIsValid() {
+    if(deregMode < CK_BUFFER_DEREG || deregMode > CK_BUFFER_NODEREG) CmiAbort("checkDeregModeIsValid: Invalid value for deregMode!\n");
+  }
+#endif
+
   public:
   // pointer to the buffer
   const void *ptr;
@@ -138,6 +148,14 @@ class CkNcpyBuffer{
 
     isRegistered = false;
 
+#if CMK_ERROR_CHECKING
+    // Ensure that regMode is valid
+    checkRegModeIsValid();
+
+    // Ensure that deregMode is valid
+    checkDeregModeIsValid();
+#endif
+
     // Register memory everytime new values are initialized
     if(cnt > 0)
       registerMem();