aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEthan Sommer <e5ten.arch@gmail.com>2020-04-16 20:16:43 -0400
committerRob Landley <rob@landley.net>2020-04-23 18:18:12 -0500
commit584cba7bae7f010b91db11ac80071d83e39643df (patch)
tree1e9bd37d2a8dccca53040fbc407a90eb838df588
parent539e66891279044d2ade4e9d2590939301c5944c (diff)
downloadtoybox-584cba7bae7f010b91db11ac80071d83e39643df.tar.gz
fdisk: fix -Wsizeof-pointer-memaccess, switch to FLAG() macros
-rw-r--r--toys/pending/fdisk.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/toys/pending/fdisk.c b/toys/pending/fdisk.c
index 4cc0190a..da0a4678 100644
--- a/toys/pending/fdisk.c
+++ b/toys/pending/fdisk.c
@@ -149,7 +149,7 @@ static void read_sec_sz()
{
int arg;
if (ioctl(dev_fd, BLKSSZGET, &arg) == 0) g_sect_size = arg;
- if (toys.optflags & FLAG_b) {
+ if (FLAG(b)) {
if (TT.sect_sz != 512 && TT.sect_sz != 1024 && TT.sect_sz != 2048 &&
TT.sect_sz != 4096)
{
@@ -375,12 +375,12 @@ static int read_mbr(char *device, int validate)
read_sec_sz();
sector_fac = g_sect_size/SECTOR_SIZE; //512 is hardware sector size.
physical_HS(&h, &s); //physical dimensions may be diferent from HDIO_GETGEO
- g_sectors = (toys.optflags & FLAG_S && TT.sectors)? TT.sectors : s? s : disk.sectors?disk.sectors : 63;
- g_heads = (toys.optflags & FLAG_H && TT.heads)? TT.heads : h? h : disk.heads? disk.heads : 255;
+ g_sectors = (FLAG(S) && TT.sectors) ? TT.sectors : s ? s : disk.sectors ? disk.sectors : 63;
+ g_heads = (FLAG(H) && TT.heads) ? TT.heads : h ? h : disk.heads ? disk.heads : 255;
g_cylinders = total_number_sectors/(g_heads * g_sectors * sector_fac);
- if (!g_cylinders) g_cylinders = toys.optflags & FLAG_C? TT.cylinders : 0;
- if ((g_cylinders > ONE_K) && !(toys.optflags & (FLAG_l | FLAG_S)))
+ if (!g_cylinders) g_cylinders = FLAG(C) ? TT.cylinders : 0;
+ if ((g_cylinders > ONE_K) && !(FLAG(l) || FLAG(S)))
xprintf("\nThe number of cylinders for this disk is set to %lu.\n"
"There is nothing wrong with that, but this is larger than 1024,\n"
"and could in certain setups cause problems.\n", g_cylinders);
@@ -1447,7 +1447,7 @@ static void read_and_print_parts()
while (fgets(buffer, ONE_K, fp)) {
reset_entries();
num_parts = 4;
- memset(name, 0, sizeof(name));
+ memset(name, 0, sizeof(*name));
if (sscanf(buffer, " %u %u %u %[^\n ]", &ma, &mi, &sz, name) != 4)
continue;
@@ -1469,8 +1469,8 @@ void fdisk_main(void)
move_fd();
if (TT.heads >= 256) TT.heads = 0;
if (TT.sectors >= 64) TT.sectors = 0;
- if (toys.optflags & FLAG_u) disp_unit_cyl = 0;
- if (toys.optflags & FLAG_l) {
+ if (FLAG(u)) disp_unit_cyl = 0;
+ if (FLAG(l)) {
if (!toys.optc) read_and_print_parts();
else {
while(*toys.optargs){