Update to zig 0.12.0 (#2)

This commit is contained in:
Vesim
2024-04-26 23:17:36 +02:00
committed by GitHub
parent 9e4ee57ec2
commit 51c49c38d8
7 changed files with 30 additions and 30 deletions

View File

@@ -2,7 +2,7 @@ const std = @import("std");
const gpio = @import("gpio");
pub fn main() !void {
var iter_dir = try std.fs.openIterableDirAbsolute("/dev", .{});
var iter_dir = try std.fs.openDirAbsolute("/dev", .{ .iterate = true });
defer iter_dir.close();
const stdout = std.io.getStdOut().writer();
@@ -11,7 +11,7 @@ pub fn main() !void {
while (try iter.next()) |entry| {
if (!hasPrefix(entry.name, "gpiochip")) continue;
const fl = try iter_dir.dir.openFile(entry.name, .{});
const fl = try iter_dir.openFile(entry.name, .{});
var chip = try gpio.getChipByFd(fl.handle);
defer chip.close(); // This will close the fd

View File

@@ -16,7 +16,7 @@ pub fn main() !void {
return error.InsufficientArguments;
}
var path: []const u8 = if (hasPrefix(args[1], "gpiochip"))
const path: []const u8 = if (hasPrefix(args[1], "gpiochip"))
try std.mem.concat(alloc, u8, &.{ "/dev/", args[1] })
else
try std.mem.concat(alloc, u8, &.{ "/dev/gpiochip", args[1] });
@@ -32,7 +32,7 @@ pub fn main() !void {
// Iterate over each argument starting from the second one
for (args[2..args.len]) |argument| {
// Parse each argument as an integer and add it to offsets
var offset = try std.fmt.parseUnsigned(u32, argument, 10);
const offset = try std.fmt.parseUnsigned(u32, argument, 10);
try offsets.append(offset);
}

View File

@@ -18,7 +18,7 @@ pub fn main() !void {
// If the argument has the "gpiochip" prefix,
// just use it unchanged. Otherwise, add the prefix.
var filename: []const u8 = if (hasGpiochip)
const filename: []const u8 = if (hasGpiochip)
argument
else
try std.mem.concat(alloc, u8, &.{ "gpiochip", argument });

View File

@@ -16,7 +16,7 @@ pub fn main() !void {
return error.InsufficientArguments;
}
var path: []const u8 = if (hasPrefix(args[1], "gpiochip"))
const path: []const u8 = if (hasPrefix(args[1], "gpiochip"))
try std.mem.concat(alloc, u8, &.{ "/dev/", args[1] })
else
try std.mem.concat(alloc, u8, &.{ "/dev/gpiochip", args[1] });
@@ -34,8 +34,8 @@ pub fn main() !void {
// Get the index of the equals sign in the argument
const eqIndex = std.mem.indexOf(u8, argument, "=") orelse return error.InvalidArgument;
// Parse each argument's offset and value, and add it to the values map
var offset = try std.fmt.parseUnsigned(u32, argument[0..eqIndex], 10);
var value = try std.fmt.parseUnsigned(u1, argument[eqIndex + 1 .. argument.len], 10);
const offset = try std.fmt.parseUnsigned(u32, argument[0..eqIndex], 10);
const value = try std.fmt.parseUnsigned(u1, argument[eqIndex + 1 .. argument.len], 10);
try values.put(offset, value != 0);
}