Project

General

Profile

Actions

Bug #81

closed

remove 'is_z_a_power_of_x_le_y' from pcfs utils

Added by John Doe over 13 years ago. Updated over 12 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
cmd - userland programs
Start date:
2010-08-23
Due date:
% Done:

0%

Estimated time:
Difficulty:
Bite-size
Tags:
needs-triage
Gerrit CR:
External Bug:

Description

This piece in cmd/fs.d/pcfs/fsck/pcfs_common.c:

69 int 
70 is_z_a_power_of_x_le_y(int x, int y, int z)
71 {
72 int ispower = 0;
73 int pow = 1;
74
75 do {
76 if (pow == z) {
77 ispower = 1;
78 break;
79 }
80 pow *= x;
81 } while (pow <= y);
82
83 return (ispower);
84 }

is embarrassing, given that the ISP2 macro from <sys/sysmacros.h> is ancient, and that the above function is used in exactly one place only, in cmd/fs.d/pcfs/fsck/bpb.c, to check against a power of two ...

Dump the cruft. Recording this here as memory backup.
What about powerofx_le_y() in mkfs.c? Can that also die?
Thanks for spotting. The two files appear to originate from the same cut&pasted source, they share a lot including the cruft.

What do you think about fsck/inject.c ? Dump it completely in favour of doing such things with DTrace ?
I don't think that would be appropriate; DTrace really isn't intended
to be a fault injection framework.

Actions #1

Updated by John Doe over 13 years ago

  • Assignee set to John Doe
Actions #2

Updated by Gary Mills over 12 years ago

  • Difficulty set to Medium
  • Tags set to needs-triage

Changing from:

if (!(is_z_a_power_of_x_le_y(2, 128, num)))

to:

if (!(ISP2 && (num >= 1) && (num <= 128)))

produces the same results without needing that function.

The hard part will be to verify that fsck and mkfs behave
identically after that change.

Actions #3

Updated by Garrett D'Amore over 12 years ago

  • Category set to cmd - userland programs
  • Status changed from New to Resolved
  • Assignee changed from John Doe to Gary Mills
  • Difficulty changed from Medium to Bite-size

Resolved in:

garrett@thinkpad{15}> hg head
changeset: 13426:f92414e708c0
tag: tip
user: Gary Mills <>
date: Thu Aug 11 10:31:52 2011 -0700
description:
81 remove 'is_z_a_power_of_x_le_y' from pcfs utils
Reviewed by: Eric Schrock <>
Reviewed by: Gordon Ross <>
Approved by: Garrett D'Amore <>

Actions

Also available in: Atom PDF