The printf functions already support printing the errno value as a
string, there is no need to convert it manually.
Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
int hiddev_write(const unsigned char data[64], int fd , int usage_code)
{
int hiddev_write(const unsigned char data[64], int fd , int usage_code)
{
- int rc = 0, uindex, error;
struct hiddev_usage_ref uref;
struct hiddev_report_info rinfo;
struct hiddev_usage_ref uref;
struct hiddev_report_info rinfo;
err2:
printf("HIDIOCSREPORT\n");
err:
err2:
printf("HIDIOCSREPORT\n");
err:
- error = errno;
- printf("Error in IOCTL: %s\n", strerror(error));
+ printf("Error in IOCTL: %m\n");
static int get_usagecode(int fd)
{
struct hiddev_usage_ref uref;
static int get_usagecode(int fd)
{
struct hiddev_usage_ref uref;
uref.report_type = HID_REPORT_TYPE_OUTPUT;
uref.report_id = 0x0;
uref.report_type = HID_REPORT_TYPE_OUTPUT;
uref.report_id = 0x0;
rc = ioctl(fd, HIDIOCGUCODE, &uref);
if (rc < 0) {
rc = ioctl(fd, HIDIOCGUCODE, &uref);
if (rc < 0) {
- error = errno;
- printf("Error gettin usage code: %s\n", strerror(error));
+ printf("Error gettin usage code: %m\n");
dir = opendir(HIDDEV_PATH);
if (dir == NULL) {
error = errno;
dir = opendir(HIDDEV_PATH);
if (dir == NULL) {
error = errno;
- trace(4, "Failed to open directory %s: %s\n", HIDDEV_PATH,
- strerror(error));
+ trace(4, "Failed to open directory %s: %m\n", HIDDEV_PATH);
+
if (errno) {
error = errno;
if (errno) {
error = errno;
- trace(0, "Error reading directory %s: %s\n", HIDDEV_PATH,
- strerror(error));
+ trace(0, "Error reading directory %s: %m\n", HIDDEV_PATH);
+
int main(int argc, char *argv[])
{
struct user_options opts;
int main(int argc, char *argv[])
{
struct user_options opts;
- int fd, usage_code, ret, error;
+ int fd, usage_code, ret;
bzero(&opts, sizeof(opts));
opts.output_format = CLEAN;
bzero(&opts, sizeof(opts));
opts.output_format = CLEAN;
if (opts.output_path) {
opts.outf = fopen(opts.output_path, "w");
if (opts.outf == NULL) {
if (opts.output_path) {
opts.outf = fopen(opts.output_path, "w");
if (opts.outf == NULL) {
- error = errno;
- trace(0, "Failed to open output file %s: %s\n",
- opts.output_path, strerror(error));
+ trace(0, "Failed to open output file \"%s\": %m\n",
+ opts.output_path);