Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use const #16459

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions misctools/features.zig
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ const Features = @import("../src/analytics/analytics_thread.zig").Features;

// zig run --main-pkg-path ../ ./features.zig
pub fn main() anyerror!void {
var stdout_ = std.io.getStdOut();
var stderr_ = std.io.getStdErr();
const stdout_ = std.io.getStdOut();
const stderr_ = std.io.getStdErr();
var output_source = Output.Source.init(stdout_, stderr_);
Output.Source.set(&output_source);
defer Output.flush();

var writer = Output.writer();
const writer = Output.writer();
try Features.Serializer.writeAll(@TypeOf(writer), writer);
}
10 changes: 5 additions & 5 deletions misctools/machbench.zig
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub fn machMain(runs: usize) anyerror!void {
defer Output.flush();
waker = try bun.Async.Waker.init(bun.default_allocator);

var args = try std.process.argsAlloc(bun.default_allocator);
const args = try std.process.argsAlloc(bun.default_allocator);
const count = std.fmt.parseInt(usize, args[args.len - 1], 10) catch 1024;
var elapsed: u64 = 0;

Expand Down Expand Up @@ -86,7 +86,7 @@ pub fn userMain(runs: usize) anyerror!void {
defer Output.flush();
user_waker = try bun.Async.UserFilterWaker.init(bun.default_allocator);

var args = try std.process.argsAlloc(bun.default_allocator);
const args = try std.process.argsAlloc(bun.default_allocator);
const count = std.fmt.parseInt(usize, args[args.len - 1], 10) catch 1024;
var remaining_runs = runs;
var elapsed: u64 = 0;
Expand Down Expand Up @@ -116,12 +116,12 @@ pub fn userMain(runs: usize) anyerror!void {
}

pub fn main() anyerror!void {
var stdout_ = std.io.getStdOut();
var stderr_ = std.io.getStdErr();
const stdout_ = std.io.getStdOut();
const stderr_ = std.io.getStdErr();
var output_source = Output.Source.init(stdout_, stderr_);
Output.Source.set(&output_source);

var args = try std.process.argsAlloc(bun.default_allocator);
const args = try std.process.argsAlloc(bun.default_allocator);
const count = std.fmt.parseInt(usize, args[args.len - 1], 10) catch 1024;
Output.prettyErrorln("For {d} messages and {d} threads:", .{ count, thread_count });
Output.flush();
Expand Down
10 changes: 5 additions & 5 deletions misctools/readlink-getfd.zig
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ const C = bun.C;

// zig build-exe -Doptimize=ReleaseFast --main-pkg-path ../ ./readlink-getfd.zig
pub fn main() anyerror!void {
var stdout_ = std.io.getStdOut();
var stderr_ = std.io.getStdErr();
const stdout_ = std.io.getStdOut();
const stderr_ = std.io.getStdErr();
var output_source = Output.Source.init(stdout_, stderr_);
Output.Source.set(&output_source);
defer Output.flush();

var args_buffer: [8192 * 2]u8 = undefined;
var fixed_buffer = std.heap.FixedBufferAllocator.init(&args_buffer);
var allocator = fixed_buffer.allocator();
const allocator = fixed_buffer.allocator();

var args = std.mem.bytesAsSlice([]u8, try std.process.argsAlloc(allocator));
const args = std.mem.bytesAsSlice([]u8, try std.process.argsAlloc(allocator));

const to_resolve = args[args.len - 1];
const cwd = try bun.getcwdAlloc(allocator);
Expand All @@ -35,7 +35,7 @@ pub fn main() anyerror!void {
while (j < 1000) : (j += 1) {
var parts = [1][]const u8{to_resolve};
var joined_buf: bun.PathBuffer = undefined;
var joined = path_handler.joinAbsStringBuf(
const joined = path_handler.joinAbsStringBuf(
cwd,
&joined_buf,
&parts,
Expand Down
8 changes: 4 additions & 4 deletions misctools/readlink-realpath.zig
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ const C = bun.C;

// zig build-exe -Doptimize=ReleaseFast --main-pkg-path ../ ./readlink-getfd.zig
pub fn main() anyerror!void {
var stdout_ = std.io.getStdOut();
var stderr_ = std.io.getStdErr();
const stdout_ = std.io.getStdOut();
const stderr_ = std.io.getStdErr();
var output_source = Output.Source.init(stdout_, stderr_);
Output.Source.set(&output_source);
defer Output.flush();

var args_buffer: [8192 * 2]u8 = undefined;
var fixed_buffer = std.heap.FixedBufferAllocator.init(&args_buffer);
var allocator = fixed_buffer.allocator();
const allocator = fixed_buffer.allocator();

var args = std.mem.bytesAsSlice([]u8, try std.process.argsAlloc(allocator));
const args = std.mem.bytesAsSlice([]u8, try std.process.argsAlloc(allocator));

const to_resolve = args[args.len - 1];
var out_buffer: bun.PathBuffer = undefined;
Expand Down
10 changes: 5 additions & 5 deletions misctools/tgz.zig
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ var buf: [32 * 1024 * 1024]u8 = undefined;
// zig build-exe -Doptimize=ReleaseFast --main-pkg-path ../ ./tgz.zig ../src/deps/zlib/libz.a ../src/deps/libarchive.a -lc -liconv
// zig build-exe -Doptimize=ReleaseFast --main-pkg-path ../ ./tgz.zig ../src/deps/zlib/libz.a ../src/deps/libarchive.a -lc -liconv
pub fn main() anyerror!void {
var stdout_ = std.io.getStdOut();
var stderr_ = std.io.getStdErr();
const stdout_ = std.io.getStdOut();
const stderr_ = std.io.getStdErr();
var output_source = Output.Source.init(stdout_, stderr_);
Output.Source.set(&output_source);
defer Output.flush();
var args = try std.process.argsAlloc(std.heap.c_allocator);
const args = try std.process.argsAlloc(std.heap.c_allocator);
if (args.len < 2) {
Output.prettyErrorln("<r><b>usage<r>: tgz ./tar.gz", .{});
Global.exit(1);
Expand All @@ -49,15 +49,15 @@ pub fn main() anyerror!void {

const tarball_path = path_handler.joinAbsStringBuf(try bun.getcwdAlloc(std.heap.c_allocator), &tarball_path_buf, &parts, .auto);
Output.prettyErrorln("Tarball Path: {s}", .{tarball_path});
var folder = basename;
const folder = basename;

// var dir = try std.fs.cwd().makeOpenPath(folder, .{ .iterate = true });

var tarball = try std.fs.openFileAbsolute(tarball_path, .{ .mode = .read_only });

var tarball_buf_list = std.ArrayListUnmanaged(u8){};

var file_size = try tarball.getEndPos();
const file_size = try tarball.getEndPos();
var file_buf: []u8 = undefined;
var file_buf_cap: usize = 0;

Expand Down
Loading