|
|
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
On Mon, May 7, 2012 at 4:12 PM, Tetsuo Handa
<penguin-kernel@xxxxxxxxxxxxxxxxxxx> wrote:
> James Morris wrote:
>> On Sat, 5 May 2012, Tetsuo Handa wrote:
>>
>> > Adarsh J wrote:
>> > > mpi_resize() returns -ENOMEM on error and 0 on success.
>> >
>> > Good catch.
>> >
>> > But it seems to me that mpi_fromstr() has no in-tree users.
>> > Also, mpi_fromstr() in RHEL 5.8/6.2 has no users.
>> > We forgot to exclude when adding MPI support?
>>
>> If that's the case, then it should be removed.
>>
>> (Removed root@ from cc:)
>>
>
> $ grep -Fr fromstr .
> ./lib/mpi/mpicoder.c:int mpi_fromstr(MPI val, const char *str)
> ./lib/mpi/mpicoder.c:EXPORT_SYMBOL_GPL(mpi_fromstr);
> ./include/linux/mpi.h:int mpi_fromstr(MPI val, const char *str);
>
> No match. We can probably remove it.
> ----------------------------------------
> >From 352a479df2a4ee1dc17fc8515602854772ec06ba Mon Sep 17 00:00:00 2001
> From: Tetsuo Handa <penguin-kernel@xxxxxxxxxxxxxxxxxxx>
> Date: Mon, 7 May 2012 22:04:05 +0900
> Subject: [PATCH] lib/mpi: Remove unused mpi_fromstr
>
> Adarsh found that checking return value of mpi_resize() in mpi_fromstr() is
> wrong. However, mpi_fromstr() is used by nobody. Remove it.
>
> Reported-by: Adarsh J <root@xxxxxxxxxxxxx>
> Signed-off-by: Tetsuo Handa <penguin-kernel@xxxxxxxxxxxxxxxxxxx>
> ---
> include/linux/mpi.h | 1 -
> lib/mpi/mpicoder.c | 75 ---------------------------------------------------
> 2 files changed, 0 insertions(+), 76 deletions(-)
>
> diff --git a/include/linux/mpi.h b/include/linux/mpi.h
> index d02cca6..e6f425d 100644
> --- a/include/linux/mpi.h
> +++ b/include/linux/mpi.h
> @@ -77,7 +77,6 @@ void mpi_swap(MPI a, MPI b);
> /*-- mpicoder.c --*/
> MPI do_encode_md(const void *sha_buffer, unsigned nbits);
> MPI mpi_read_from_buffer(const void *buffer, unsigned *ret_nread);
> -int mpi_fromstr(MPI val, const char *str);
> u32 mpi_get_keyid(MPI a, u32 *keyid);
> void *mpi_get_buffer(MPI a, unsigned *nbytes, int *sign);
> void *mpi_get_secure_buffer(MPI a, unsigned *nbytes, int *sign);
> diff --git a/lib/mpi/mpicoder.c b/lib/mpi/mpicoder.c
> index f26b41f..f0fa659 100644
> --- a/lib/mpi/mpicoder.c
> +++ b/lib/mpi/mpicoder.c
> @@ -74,81 +74,6 @@ leave:
> EXPORT_SYMBOL_GPL(mpi_read_from_buffer);
>
> /****************
> - * Make an mpi from a character string.
> - */
> -int mpi_fromstr(MPI val, const char *str)
> -{
> - int hexmode = 0, sign = 0, prepend_zero = 0, i, j, c, c1, c2;
> - unsigned nbits, nbytes, nlimbs;
> - mpi_limb_t a;
> -
> - if (*str == '-') {
> - sign = 1;
> - str++;
> - }
> - if (*str == '0' && str[1] == 'x')
> - hexmode = 1;
> - else
> - return -EINVAL; /* other bases are not yet supported */
> - str += 2;
> -
> - nbits = strlen(str) * 4;
> - if (nbits % 8)
> - prepend_zero = 1;
> - nbytes = (nbits + 7) / 8;
> - nlimbs = (nbytes + BYTES_PER_MPI_LIMB - 1) / BYTES_PER_MPI_LIMB;
> - if (val->alloced < nlimbs)
> - if (!mpi_resize(val, nlimbs))
> - return -ENOMEM;
> - i = BYTES_PER_MPI_LIMB - nbytes % BYTES_PER_MPI_LIMB;
> - i %= BYTES_PER_MPI_LIMB;
> - j = val->nlimbs = nlimbs;
> - val->sign = sign;
> - for (; j > 0; j--) {
> - a = 0;
> - for (; i < BYTES_PER_MPI_LIMB; i++) {
> - if (prepend_zero) {
> - c1 = '0';
> - prepend_zero = 0;
> - } else
> - c1 = *str++;
> - assert(c1);
> - c2 = *str++;
> - assert(c2);
> - if (c1 >= '0' && c1 <= '9')
> - c = c1 - '0';
> - else if (c1 >= 'a' && c1 <= 'f')
> - c = c1 - 'a' + 10;
> - else if (c1 >= 'A' && c1 <= 'F')
> - c = c1 - 'A' + 10;
> - else {
> - mpi_clear(val);
> - return 1;
> - }
> - c <<= 4;
> - if (c2 >= '0' && c2 <= '9')
> - c |= c2 - '0';
> - else if (c2 >= 'a' && c2 <= 'f')
> - c |= c2 - 'a' + 10;
> - else if (c2 >= 'A' && c2 <= 'F')
> - c |= c2 - 'A' + 10;
> - else {
> - mpi_clear(val);
> - return 1;
> - }
> - a <<= 8;
> - a |= c;
> - }
> - i = 0;
> -
> - val->d[j - 1] = a;
> - }
> -
> - return 0;
> -}
> -EXPORT_SYMBOL_GPL(mpi_fromstr);
> -
> -/****************
> * Return an allocated buffer with the MPI (msb first).
> * NBYTES receives the length of this buffer. Caller must free the
> * return string (This function does return a 0 byte buffer with NBYTES
> --
> 1.7.1
Hei,
Wait wait...
If you look to lib/mpi/Makefile then will see CONFIG_MPILIB_EXTRA section.
There are API which is not currently used but it is there.
If we remove function-by-function then why not to remove ALL unused?
But some of those were used by DSA implementation...
In fact, isn't it so that compiler will throw away all unexported functions?
- Dmitry
��.n��������+%������w��{.n�����{��ǜ�����v�)��jg��������ݢj����G�������j:+v���w�m������w�������h�����٥
[Fedora Maintainers] [Fedora Desktop] [Fedora SELinux] [Yosemite News] [Yosemite Photos] [KDE Users] [Fedora Tools]