Commit Graph

15 Commits

Author SHA1 Message Date
Gustavo A. R. Silva 06ed6aa56f pcmcia: Replace zero-length array with flexible-array
The current codebase makes use of the zero-length array language
extension to the C90 standard, but the preferred mechanism to declare
variable-length types such as these ones is a flexible array member[1][2],
introduced in C99:

struct foo {
        int stuff;
        struct boo array[];
};

By making use of the mechanism above, we will get a compiler warning
in case the flexible array does not occur last in the structure, which
will help us prevent some kind of undefined behavior bugs from being
inadvertently introduced[3] to the codebase from now on.

Also, notice that, dynamic memory allocations won't be affected by
this change:

"Flexible array members have incomplete type, and so the sizeof operator
may not be applied. As a quirk of the original implementation of
zero-length arrays, sizeof evaluates to zero."[1]

sizeof(flexible-array-member) triggers a warning because flexible array
members have incomplete type[1]. There are some instances of code in
which the sizeof operator is being incorrectly/erroneously applied to
zero-length arrays and the result is zero. Such instances may be hiding
some bugs. So, this work (flexible-array member conversions) will also
help to get completely rid of those sorts of issues.

This issue was found with the help of Coccinelle.

[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://github.com/KSPP/linux/issues/21
[3] commit 7649773293 ("cxgb3/l2t: Fix undefined behaviour")

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
2020-05-18 10:28:31 +02:00
Thomas Gleixner d2912cb15b treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500
Based on 2 normalized pattern(s):

  this program is free software you can redistribute it and or modify
  it under the terms of the gnu general public license version 2 as
  published by the free software foundation

  this program is free software you can redistribute it and or modify
  it under the terms of the gnu general public license version 2 as
  published by the free software foundation #

extracted by the scancode license scanner the SPDX license identifier

  GPL-2.0-only

has been chosen to replace the boilerplate/reference in 4122 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Enrico Weigelt <info@metux.net>
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Allison Randal <allison@lohutok.net>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190604081206.933168790@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-06-19 17:09:55 +02:00
Dominik Brodowski ac8b422838 pcmcia: remove cs_types.h
Remove cs_types.h which is no longer needed: Most definitions aren't
used at all, a few can be made away with, and two remaining definitions
(typedefs, unfortunatley) may be moved to more specific places.

CC: linux-ide@vger.kernel.org
CC: linux-usb@vger.kernel.org
CC: laforge@gnumonks.org
CC: linux-mtd@lists.infradead.org
CC: alsa-devel@alsa-project.org
CC: linux-serial@vger.kernel.org
Acked-by: Marcel Holtmann <marcel@holtmann.org> (for drivers/bluetooth/)
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
2010-07-30 21:07:39 +02:00
Dominik Brodowski a45b3fb19b pcmcia: ioctl-internal definitions
cisinfo_t and cs_status_t are only used by the (deprecated) PCMCIA
ioctl. Therefore, move them out of the way.

Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
2008-08-31 16:00:42 +02:00
Dominik Brodowski 272433e088 pcmcia: cistpl header cleanup
16-bit PCMCIA device handling function definitions are moved to ds.h.

Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
2008-08-31 15:55:58 +02:00
Dominik Brodowski 2f3061eb10 pcmcia: remove unused argument to pcmcia_parse_tuple()
Since we're just parsing the tuple being passed to this function, we don't
need any device-specific information.

Also, remove the call to pcmcia_validate_cis() from pcmciamtd.c, since it
is already called by the PCMCIA core.

Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
2008-08-31 15:50:33 +02:00
Dominik Brodowski 994917f8b7 pcmcia: card services header cleanup
16-bit PCMCIA device handling function definitions are moved to ds.h,
internal definitions to cs_internal.h.

Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
2008-08-31 15:25:47 +02:00
Dominik Brodowski ff08705860 Merge branches 'pcmcia-config-loop' and 'pcmcia-printk' into pcmcia
* pcmcia-config-loop:
  pcmcia: pcmcia_config_loop() improvement by passing vcc
  pcmcia: pcmcia_config_loop() default CIS entry handling
  pcmcia: pcmcia_config_loop() ConfigIndex unification
  pcmcia: use pcmcia_loop_config in misc pcmcia drivers
  pcmcia: use pcmcia_loop_config in net pcmcia drivers
  pcmcia: use pcmcia_loop_config in ISDN pcmcia drivers
  pcmcia: use pcmcia_loop_config in scsi pcmcia drivers
  pcmcia: use pcmcia_loop_config in bluetooth drivers
  pcmcia: use pcmcia_loop_config in pata and ide drivers
  pcmcia: add pcmcia_loop_config() helper

* pcmcia-printk:
  pcmcia: don't add extra DEBUG cflag
  pcmcia: remove unused cs_socket_name() definition
  pcmcia: use dev_printk in module rsrc_nonstatic
  pcmcia: use dev_printk in module pcmcia
  pcmcia: use dev_printk in module pcmcia_core
  pcmcia: use dev_printk and dev_dbg in yenta_socket
2008-08-23 02:00:44 +02:00
Dominik Brodowski ad913c1192 pcmcia: pcmcia_config_loop() improvement by passing vcc
By passing the current Vcc setting to the pcmcia_config_loop callback
function, we can remove pcmcia_get_configuration_info() calls from many
drivers.

Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
2008-08-23 01:22:52 +02:00
Dominik Brodowski 8e2fc39dde pcmcia: pcmcia_config_loop() default CIS entry handling
Many drivers use the default CIS entry within their pcmcia_config_loop()
callback function. Therefore, factor the default CIS entry handling out.

Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
2008-08-23 01:22:00 +02:00
Dominik Brodowski a804b574e6 pcmcia: add pcmcia_loop_config() helper
By calling pcmcia_loop_config(), a pcmcia driver can iterate over all
available configuration options. During a driver's probe() phase, one
doesn't need to use pcmcia_get_{first,next}_tuple, pcmcia_get_tuple_data
and pcmcia_parse_tuple directly in most if not all cases.

Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
2008-08-23 00:46:35 +02:00
Dominik Brodowski 53efec9513 pcmcia: only copy CIS override data once
Instead of copying CIS override data in socket_sysfs.c or ds.c, and then again
in cistpl.c, only do so once. Also, cisdump_t is now only used by the
deprecated ioctl.

Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
2008-08-02 18:56:49 +02:00
Dominik Brodowski c5081d5f47 pcmcia: simplify pccard_validate_cis
As cisinfo_t only contains one unsigned_int, pccard_validate_cis can
be simplified by passing that around directly.

Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
2008-06-24 15:33:42 +02:00
Dominik Brodowski 1540eec5e5 [PATCH] pcmcia: remove pcmcia_compat.c
Remove the compatibility wrappers, as they can (now) also be implemented
using macros. Please continue using these wrappers instead of new functions
until a new API has stabilized.

Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
2006-03-31 17:02:33 +02:00
Linus Torvalds 1da177e4c3 Linux-2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.

Let it rip!
2005-04-16 15:20:36 -07:00