RE: [PATCH 02/15] prlimit: add opt_id array to match short options to limit ids

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Karel Zak wrote:

> On Mon, Nov 14, 2011 at 02:48:04AM +0100, Bernhard Voelker wrote:
> > +	static const size_t opt_id[] = {
> > +		['c'] = CORE,
> > +		['d'] = DATA,
> > +		['e'] = NICE,
> > +		['f'] = FSIZE,
> > +		['i'] = SIGPENDING,
> > +		['l'] = MEMLOCK,
> > +		['m'] = RSS,
> > +		['n'] = NOFILE,
> > +		['q'] = MSGQUEUE,
> > +		['r'] = RTPRIO,
> > +		['s'] = STACK,
> > +		['t'] = CPU,
> > +		['u'] = NPROC,
> > +		['v'] = AS,
> > +		['x'] = LOCKS,
> > +		['y'] = RTTIME
> > +		/* h = help, o = output columns, p = pid, V = version */
> > +	};
> 
>  Sorry, not applied. This change does not make the code more robust or
>  readable and does not fix any error.

Later on in [PATCH 11/15], I needed do n++ in a separate statement in
each case (because lims[] is no longer filled as arguments can be parsed
but instead, there's one element per limit type.

@@ -573,7 +584,8 @@ int main(int argc, char **argv)
  		case 'v':
  		case 'x':
  		case 'y':
-				add_prlim(optarg, &lims[n++], opt_id[opt]);
+				add_prlim(optarg, &lims[opt_id[opt]], opt_id[opt]);
+				n++;
  				break;

This additional statement made the switch/case rather huge.

Berny--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux