Diff for /embedaddon/libnet/src/libnet_cq.c between versions 1.1.1.3 and 1.1.1.4

version 1.1.1.3, 2021/03/16 23:47:28 version 1.1.1.4, 2023/09/27 11:11:38
Line 31 Line 31
  *   *
  */   */
   
#if (HAVE_CONFIG_H)#include "common.h"
#include "../include/config.h" 
#endif 
#if (!(_WIN32) || (__CYGWIN__))  
#include "../include/libnet.h" 
#else 
#include "../include/win32/libnet.h" 
#endif 
   
 /* private function prototypes */  /* private function prototypes */
 static libnet_cq_t *libnet_cq_find_internal(libnet_t *);  static libnet_cq_t *libnet_cq_find_internal(libnet_t *);
Line 51  static libnet_cqd_t l_cqd = {0, CQ_LOCK_UNLOCKED, NULL Line 44  static libnet_cqd_t l_cqd = {0, CQ_LOCK_UNLOCKED, NULL
   
   
 static int  static int
set_cq_lock(uint x) set_cq_lock(uint32_t x) 
 {  {
     if (check_cq_lock(x))      if (check_cq_lock(x))
     {      {
Line 63  set_cq_lock(uint x)  Line 56  set_cq_lock(uint x) 
 }  }
   
 static int  static int
clear_cq_lock(uint x) clear_cq_lock(uint32_t x) 
 {  {
     if (!check_cq_lock(x))      if (!check_cq_lock(x))
     {      {
Line 88  libnet_cq_add(libnet_t *l, char *label) Line 81  libnet_cq_add(libnet_t *l, char *label)
     if (cq_is_wlocked())       if (cq_is_wlocked()) 
     {      {
         snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,          snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,
                "%s(): can't add, context queue is write locked\n", __func__);                "%s(): can't add, context queue is write locked", __func__);
         return (-1);          return (-1);
     }      }
       
     /* ensure there is a label */      /* ensure there is a label */
     if (label == NULL)      if (label == NULL)
     {      {
        snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, "%s(): empty label\n",        snprintf(l->err_buf, LIBNET_ERRBUF_SIZE, "%s(): empty label",
                 __func__);                  __func__);
         return (-1);          return (-1);
     }      }
Line 107  libnet_cq_add(libnet_t *l, char *label) Line 100  libnet_cq_add(libnet_t *l, char *label)
         if (l_cq == NULL)          if (l_cq == NULL)
         {          {
             snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,              snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,
                    "%s(): can't malloc initial context queue: %s\n",                    "%s(): can't malloc initial context queue: %s",
                     __func__, strerror(errno));                      __func__, strerror(errno));
             return (-1);              return (-1);
         }          }
Line 138  libnet_cq_add(libnet_t *l, char *label) Line 131  libnet_cq_add(libnet_t *l, char *label)
     if (l_cq == NULL)      if (l_cq == NULL)
     {      {
         snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,          snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,
                "%s(): can't malloc new context queue: %s\n",                "%s(): can't malloc new context queue: %s",
                 __func__, strerror(errno));                  __func__, strerror(errno));
         return (-1);          return (-1);
     }      }
Line 170  libnet_cq_remove(libnet_t *l)  Line 163  libnet_cq_remove(libnet_t *l) 
     if (l_cq == NULL)       if (l_cq == NULL) 
     {      {
         snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,          snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,
                "%s(): can't remove from empty context queue\n", __func__);                "%s(): can't remove from empty context queue", __func__);
         return (NULL);          return (NULL);
     }      }
   
Line 183  libnet_cq_remove(libnet_t *l)  Line 176  libnet_cq_remove(libnet_t *l) 
     if (cq_is_wlocked())       if (cq_is_wlocked()) 
     {      {
         snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,          snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,
                "%s(): can't remove, context queue is write locked\n",                "%s(): can't remove, context queue is write locked",
                 __func__);                  __func__);
         return (NULL);          return (NULL);
     }      }
Line 191  libnet_cq_remove(libnet_t *l)  Line 184  libnet_cq_remove(libnet_t *l) 
     if ((p = libnet_cq_find_internal(l)) == NULL)      if ((p = libnet_cq_find_internal(l)) == NULL)
     {      {
         snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,          snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,
                "%s(): context not present in context queue\n", __func__);                "%s(): context not present in context queue", __func__);
         return (NULL);          return (NULL);
     }      }
   
Line 282  libnet_cq_dup_check(libnet_t *l, char *label) Line 275  libnet_cq_dup_check(libnet_t *l, char *label)
         if (p->context == l)          if (p->context == l)
         {          {
             snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,              snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,
                "%s(): context already in context queue\n", __func__);                "%s(): context already in context queue", __func__);
             return (1);              return (1);
         }          }
         if (strncmp(p->context->label, label, LIBNET_LABEL_SIZE) == 0)          if (strncmp(p->context->label, label, LIBNET_LABEL_SIZE) == 0)
         {          {
             snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,              snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,
                    "%s(): duplicate label %s\n", __func__, label);                    "%s(): duplicate label %s", __func__, label);
             return (1);              return (1);
         }          }
     }      }
Line 407  libnet_cq_end_loop() Line 400  libnet_cq_end_loop()
     return (1);      return (1);
 }  }
   
   /**
    * Local Variables:
    *  indent-tabs-mode: nil
    *  c-file-style: "stroustrup"
    * End:
    */

Removed from v.1.1.1.3  
changed lines
  Added in v.1.1.1.4


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>