aboutsummaryrefslogtreecommitdiffstats
path: root/libgamma_linux_drm_partition_initialise.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2021-03-08 00:21:02 +0100
committerMattias Andrée <maandree@kth.se>2021-03-08 00:21:02 +0100
commitb058098fdcc5d4ed9b81fdb17f64820c0360ad48 (patch)
treee39e5f547b900922775d466507c29b352f046a53 /libgamma_linux_drm_partition_initialise.c
parentmisc (diff)
downloadlibgamma-b058098fdcc5d4ed9b81fdb17f64820c0360ad48.tar.gz
libgamma-b058098fdcc5d4ed9b81fdb17f64820c0360ad48.tar.bz2
libgamma-b058098fdcc5d4ed9b81fdb17f64820c0360ad48.tar.xz
m + style fix + check memory allocation overflows
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'libgamma_linux_drm_partition_initialise.c')
-rw-r--r--libgamma_linux_drm_partition_initialise.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/libgamma_linux_drm_partition_initialise.c b/libgamma_linux_drm_partition_initialise.c
index 8136cd9..5440365 100644
--- a/libgamma_linux_drm_partition_initialise.c
+++ b/libgamma_linux_drm_partition_initialise.c
@@ -32,7 +32,7 @@ figure_out_card_open_error(const char *pathname)
return LIBGAMMA_ERRNO_SET;
}
- /* TODO Can this be simplified? */
+ /* TODO Can this be simplified? Is this even correct? */
#define TEST(R, W) ((attr.st_mode & ((R) | (W))) == ((R) | (W)))
/* Get permission requirement for the file */
@@ -45,7 +45,7 @@ figure_out_card_open_error(const char *pathname)
return LIBGAMMA_DEVICE_ACCESS_FAILED;
/* The group should be "video", but perhaps
- it is "root" to restrict users */
+ * it is "root" to restrict users */
if (!attr.st_gid /* root group */ || TEST(S_IRGRP, S_IWGRP))
return LIBGAMMA_DEVICE_RESTRICTED;
@@ -56,19 +56,19 @@ figure_out_card_open_error(const char *pathname)
return LIBGAMMA_ERRNO_SET;
/* Test whether any of the supplemental
- group should be satisfactory */
+ * group should be satisfactory */
for (i = 0; i < n; i++)
if (supplemental_groups[i] == attr.st_gid)
break;
/* If one of the supplemental groups should be satisfactory,
- then we do not know anything more than that access failed */
+ * then we do not know anything more than that access failed */
if (i != n)
return LIBGAMMA_DEVICE_ACCESS_FAILED;
/* Otherwise, try to get the name of the group that is
- required and report the missing group membership */
- errno = getgrgid_r(attr.st_gid, &_grp, buf, sizeof(buf) / sizeof(char), &group);
+ * required and report the missing group membership */
+ errno = getgrgid_r(attr.st_gid, &_grp, buf, sizeof(buf), &group);
if (errno == ERANGE) {
/* The lenght of the group's name is absurdly long, degrade to thread-unsafe. */
errno = 0;
@@ -118,7 +118,7 @@ libgamma_linux_drm_partition_initialise(struct libgamma_partition_state *restric
data->connectors = NULL;
/* Get the pathname for the graphics card */
- snprintf(pathname, sizeof(pathname) / sizeof(char), DRM_DEV_NAME, DRM_DIR_NAME, (int)partition);
+ snprintf(pathname, sizeof(pathname), DRM_DEV_NAME, DRM_DIR_NAME, (int)partition);
/* Acquire access to the graphics card */
data->fd = open(pathname, O_RDWR | O_CLOEXEC);