[PATCH 1/3] libqmi-glib, device: new getter/setter for the expected data format in the kernel
Aleksander Morgado
aleksander at aleksander.es
Wed Jan 6 10:30:10 PST 2016
On Wed, Jan 6, 2016 at 6:04 PM, Dan Williams <dcbw at redhat.com> wrote:
>> + g_debug ("[%s] Reading expected data format from: %s",
>> + self->priv->path_display,
>> + sysfs_path);
>> +
>> + if (!(f = fopen (sysfs_path, "r"))) {
>> + g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errno),
>> + "Failed to open file '%s': %s",
>> + sysfs_path, g_strerror (errno));
>> + goto out;
>> + }
>> +
>> + if (fread (&value, 1, 1, f) != 1) {
>> + g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errno),
>> + "Failed to read from file '%s': %s",
>> + sysfs_path, g_strerror (errno));
>> + goto out;
>> + }
>
> Would just g_file_get_contents() work here? Or is that too heavy?
> Otherwise looks fine.
It did work, yes, that is how it was first implemented :) But then I
tried to use g_file_set_contents() for the setter and that one
requires an intermediate temporary file so that the full file is
replaced in a single shot, and that didn't work with sysfs files of
course... so, I just used raw C for both R/W...
--
Aleksander
https://aleksander.es
More information about the libqmi-devel
mailing list