Skip to content

Commit

Permalink
uml: Replace one-element array with zero-element array
Browse files Browse the repository at this point in the history
To look at users I did:
$ find arch/um/ include/asm-um -name '*.[ch]'|xargs grep -r 'net_kern\.h'
+-l|xargs grep '\<user\>'

Most users just cast user to the appropriate pointer, the remaining ones are
fixed here.  In net_kern.c, I'm almost sure that save trick is not needed
anymore, but I've not verified it.

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <[email protected]>
Signed-off-by: Jeff Dike <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Paolo 'Blaisorblade' Giarrusso authored and Linus Torvalds committed May 7, 2007
1 parent 8c84083 commit c74c69b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
14 changes: 3 additions & 11 deletions arch/um/drivers/net_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,10 +347,9 @@ static void eth_configure(int n, void *init, char *mac,
struct uml_net *device;
struct net_device *dev;
struct uml_net_private *lp;
int save, err, size;
int err, size;

size = transport->private_size + sizeof(struct uml_net_private) +
sizeof(((struct uml_net_private *) 0)->user);
size = transport->private_size + sizeof(struct uml_net_private);

device = kzalloc(sizeof(*device), GFP_KERNEL);
if (device == NULL) {
Expand Down Expand Up @@ -409,12 +408,6 @@ static void eth_configure(int n, void *init, char *mac,
*/
(*transport->kern->init)(dev, init);

/* lp.user is the first four bytes of the transport data, which
* has already been initialized. This structure assignment will
* overwrite that, so we make sure that .user gets overwritten with
* what it already has.
*/
save = lp->user[0];
*lp = ((struct uml_net_private)
{ .list = LIST_HEAD_INIT(lp->list),
.dev = dev,
Expand All @@ -428,8 +421,7 @@ static void eth_configure(int n, void *init, char *mac,
.write = transport->kern->write,
.add_address = transport->user->add_address,
.delete_address = transport->user->delete_address,
.set_mtu = transport->user->set_mtu,
.user = { save } });
.set_mtu = transport->user->set_mtu });

init_timer(&lp->tl);
spin_lock_init(&lp->lock);
Expand Down
2 changes: 1 addition & 1 deletion arch/um/include/net_kern.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct uml_net_private {
void (*add_address)(unsigned char *, unsigned char *, void *);
void (*delete_address)(unsigned char *, unsigned char *, void *);
int (*set_mtu)(int mtu, void *);
int user[1];
char user[0];
};

struct net_kern_info {
Expand Down

0 comments on commit c74c69b

Please sign in to comment.