]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[IRDA]: Use kmemdup where applicable
authorArnaldo Carvalho de Melo <acme@mandriva.com>
Tue, 21 Nov 2006 03:18:33 +0000 (01:18 -0200)
committerDavid S. Miller <davem@sunset.davemloft.net>
Sun, 3 Dec 2006 05:30:17 +0000 (21:30 -0800)
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
net/irda/iriap.c
net/irda/irias_object.c
net/irda/irlmp.c
net/irda/irqueue.c

index ab86d70393ea4323faedd13da50f78aacca875ce..8cfd076c4c12ae3db3947d201a514e9b1cee2179 100644 (file)
@@ -172,7 +172,7 @@ struct iriap_cb *iriap_open(__u8 slsap_sel, int mode, void *priv,
 
        IRDA_DEBUG(2, "%s()\n", __FUNCTION__);
 
-       self = kmalloc(sizeof(struct iriap_cb), GFP_ATOMIC);
+       self = kzalloc(sizeof(*self), GFP_ATOMIC);
        if (!self) {
                IRDA_WARNING("%s: Unable to kmalloc!\n", __FUNCTION__);
                return NULL;
@@ -181,7 +181,6 @@ struct iriap_cb *iriap_open(__u8 slsap_sel, int mode, void *priv,
        /*
         *  Initialize instance
         */
-       memset(self, 0, sizeof(struct iriap_cb));
 
        self->magic = IAS_MAGIC;
        self->mode = mode;
index 56292ab7d6522861d5d5be01983d54e170869ef0..b1ee99a59c0cee416137e1d4cbcb371117d6a271 100644 (file)
@@ -501,13 +501,12 @@ struct ias_value *irias_new_octseq_value(__u8 *octseq , int len)
                len = IAS_MAX_OCTET_STRING;
        value->len = len;
 
-       value->t.oct_seq = kmalloc(len, GFP_ATOMIC);
+       value->t.oct_seq = kmemdup(octseq, len, GFP_ATOMIC);
        if (value->t.oct_seq == NULL){
                IRDA_WARNING("%s: Unable to kmalloc!\n", __FUNCTION__);
                kfree(value);
                return NULL;
        }
-       memcpy(value->t.oct_seq, octseq , len);
        return value;
 }
 
@@ -522,7 +521,6 @@ struct ias_value *irias_new_missing_value(void)
        }
 
        value->type = IAS_MISSING;
-       value->len = 0;
 
        return value;
 }
index fede83763095085c36d4866c29eeb08d477464e5..7e5d12ab3b90dd1f580465089a6b150377eb07b9 100644 (file)
@@ -641,15 +641,13 @@ struct lsap_cb *irlmp_dup(struct lsap_cb *orig, void *instance)
        }
 
        /* Allocate a new instance */
-       new = kmalloc(sizeof(struct lsap_cb), GFP_ATOMIC);
+       new = kmemdup(orig, sizeof(*new), GFP_ATOMIC);
        if (!new)  {
                IRDA_DEBUG(0, "%s(), unable to kmalloc\n", __FUNCTION__);
                spin_unlock_irqrestore(&irlmp->unconnected_lsaps->hb_spinlock,
                                       flags);
                return NULL;
        }
-       /* Dup */
-       memcpy(new, orig, sizeof(struct lsap_cb));
        /* new->lap = orig->lap; => done in the memcpy() */
        /* new->slsap_sel = orig->slsap_sel; => done in the memcpy() */
        new->conn_skb = NULL;
index 1ba8c7106639604f9ed91f8acff0afdc2ed5f170..1d26cd33ea13af07bbc22e53df6ce54c02f3e759 100644 (file)
@@ -356,14 +356,13 @@ hashbin_t *hashbin_new(int type)
        /*
         * Allocate new hashbin
         */
-       hashbin = kmalloc( sizeof(hashbin_t), GFP_ATOMIC);
+       hashbin = kzalloc(sizeof(*hashbin), GFP_ATOMIC);
        if (!hashbin)
                return NULL;
 
        /*
         * Initialize structure
         */
-       memset(hashbin, 0, sizeof(hashbin_t));
        hashbin->hb_type = type;
        hashbin->magic = HB_MAGIC;
        //hashbin->hb_current = NULL;