Bug in the pNFS OSD layout driver

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

 



Hi Boaz,

When I run 'sparse' on the object layout driver, I get the following
errors:

fs/nfs/objlayout/objio_osd.c:210:37: error: bad constant expression
fs/nfs/objlayout/objio_osd.c:211:39: error: bad constant expression
fs/nfs/objlayout/objio_osd.c:315:59: error: bad constant expression

which boils down to the following section of code:

int __alloc_objio_seg(unsigned numdevs, gfp_t gfp_flags,
                       struct objio_segment **pseg)
{
        struct __alloc_objio_segment {
                struct objio_segment olseg;
                struct ore_dev *ods[numdevs];
		^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                struct ore_comp comps[numdevs];
		^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        } *aolseg;

        aolseg = kzalloc(sizeof(*aolseg), gfp_flags);


Dynamically allocated arrays such as the above are a GNU C compiler
feature that we cannot use in kernel code. If the above array sizes need
to be dynamically determined, then please use the kcalloc() interface to
allocate them.
I.e. something like

        struct __alloc_objio_segment {
                struct objio_segment olseg;
                struct ore_dev **ods;
                struct ore_comp *comps;
		^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        } *aolseg;

        aolseg = kzalloc(sizeof(*aolseg), gfp_flags);
	if (aolseg) {
		aolseg->ods = kcalloc(numdevs, sizeof(struct ore_dev *), gfp_flags);
		aolseg->ore_comp = kcalloc(numdevs, sizeof(struct ore_comp), gfp_flags);
		if (!aolseg->ods || !aolseg->ore_comp)
			.... clean up and report error...
	}

Cheers
  Trond
-- 
Trond Myklebust
Linux NFS client maintainer

NetApp
Trond.Myklebust@xxxxxxxxxx
www.netapp.com

��.n��������+%������w��{.n�����{��w���jg��������ݢj����G�������j:+v���w�m������w�������h�����٥



[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux