[apparmor] [PATCH 06/12] libapparmor: Move the aa_features API
Seth Arnold
seth.arnold at canonical.com
Sat Feb 14 02:25:00 UTC 2015
On Wed, Dec 10, 2014 at 04:12:27PM -0600, Tyler Hicks wrote:
> Signed-off-by: Tyler Hicks <tyhicks at canonical.com>
Acked-by: Seth Arnold <seth.arnold at canonical.com>
A few small suggestions:
> +static int features_dir_cb(DIR *dir, const char *name, struct stat *st,
> + void *data)
> +{
> + struct features_struct *fst = (struct features_struct *) data;
> + int remaining, len;
> +
> + /* skip dot files and files with no name */
> + if (*name == '.' || !strlen(name))
> + return 0;
I don't know what a file with no name looks like but the !strlen(name)
could be replaced by *name == '\0'.
> +int aa_features_new(aa_features **features, const char *path)
> +{
> + struct stat stat_file;
> + aa_features *f;
> + int retval;
> +
> + *features = NULL;
> +
> + if (stat(path, &stat_file) == -1)
> + return -1;
> +
> + f = (aa_features *) calloc(1, sizeof(*f));
> +int aa_features_new_from_string(aa_features **features,
> + const char *string, size_t size)
> +{
> + aa_features *f;
> +
> + *features = NULL;
> +
> + /* Require size to be less than STRING_SIZE so there's room for a NUL */
> + if (size >= STRING_SIZE)
> + return ENOBUFS;
> +
> + f = (aa_features *) calloc(1, sizeof(*f));
Are these casts necessary? Normally calls for the malloc() family don't
need casting if there is a prototype in scope, and it looked like the
header should be included for these files.
Thanks
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20150213/c82eee71/attachment.pgp>
More information about the AppArmor
mailing list