lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 24 Aug 2009 08:41:28 -0700
From:	Dave Hansen <dave@...ux.vnet.ibm.com>
To:	David Rientjes <rientjes@...gle.com>
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	linux-kernel@...r.kernel.org
Subject: Re: [patch 2/4 -mm] flex_array: add flex_array_clear function

On Fri, 2009-08-21 at 16:21 -0700, David Rientjes wrote:
>  /**
> + * flex_array_clear - clear element in array at @element_nr
> + * @element_nr:        index of the position to clear.
> + *
> + * Locking must be provided by the caller.
> + */
> +int flex_array_clear(struct flex_array *fa, unsigned int element_nr)
> +{
> +       int part_nr = fa_element_to_part_nr(fa, element_nr);
> +       struct flex_array_part *part;
> +       void *dst;
> +
> +       if (element_nr >= fa->total_nr_elements)
> +               return -ENOSPC;
> +       if (elements_fit_in_base(fa))
> +               part = (struct flex_array_part *)&fa->parts[0];
> +       else {
> +               part = fa->parts[part_nr];
> +               if (!part)
> +                       return -EINVAL;
> +       }
> +       dst = &part->elements[index_inside_part(fa, element_nr)];
> +       memset(dst, 0, fa->element_size);
> +       return 0;
> +}

My only worry about this is that it's largely a copy-and-paste of
flex_array_put().  If we had a function that just returned a pointer to
'dst', we could use that in both cases.  

Couldn't we implement the above with just:

int flex_array_clear(struct flex_array *fa, unsigned int element_nr)
{
	return flex_array_put(fa, element_nr, &empty_zero_page);
}

-- Dave

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ