vlog: Add VLOG_WARN_ONCE() and similar macros.
[sliver-openvswitch.git] / lib / dpif-linux.c
index 432d5ed..ec8a952 100644 (file)
@@ -41,9 +41,9 @@
 #include "shash.h"
 #include "svec.h"
 #include "util.h"
-
 #include "vlog.h"
-#define THIS_MODULE VLM_dpif_linux
+
+VLOG_DEFINE_THIS_MODULE(dpif_linux)
 
 /* Datapath interface for the openvswitch Linux kernel module. */
 struct dpif_linux {
@@ -478,8 +478,7 @@ dpif_linux_recv(struct dpif *dpif_, struct ofpbuf **bufp)
     int retval;
     int error;
 
-    buf = ofpbuf_new(65536 + DPIF_RECV_MSG_PADDING);
-    ofpbuf_reserve(buf, DPIF_RECV_MSG_PADDING);
+    buf = ofpbuf_new_with_headroom(65536, DPIF_RECV_MSG_PADDING);
     retval = read(dpif->fd, ofpbuf_tail(buf), ofpbuf_tailroom(buf));
     if (retval < 0) {
         error = errno;
@@ -732,11 +731,7 @@ get_major(const char *target)
                 return major;
             }
         } else {
-            static bool warned;
-            if (!warned) {
-                VLOG_WARN("%s:%d: syntax error", fn, ln);
-            }
-            warned = true;
+            VLOG_WARN_ONCE("%s:%d: syntax error", fn, ln);
         }
     }