Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1247977

[PATCH 1/2] bitops.h: Improve sign_extend32()'s documentation

From Martin Kepplinger <martink@posteo.de>
Newsgroups linux.kernel
Subject [PATCH 1/2] bitops.h: Improve sign_extend32()'s documentation
Date 2015-10-15 18:30 +0200
Message-ID <qjTzI-3md-13@gated-at.bofh.it> (permalink)
References <qjTzI-3md-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


It is often overlooked that sign_extend32(), despite it's name, is safe
to use for 16 and 8 bit types aswell. This should help that sign extension
isn't done manually some other way.

Signed-off-by: Martin Kepplinger <martin.kepplinger@theobroma-systems.com>
---
 include/linux/bitops.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index e635533..2177c01 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -164,6 +164,8 @@ static inline __u8 ror8(__u8 word, unsigned int shift)
  * sign_extend32 - sign extend a 32-bit value using specified bit as sign-bit
  * @value: value to sign extend
  * @index: 0 based bit index (0<=index<32) to sign bit
+ *
+ * This is safe to use for 16- and 8-bit types aswell.
  */
 static inline __s32 sign_extend32(__u32 value, int index)
 {
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

bitops.h: improve sign extending API Martin Kepplinger <martink@posteo.de> - 2015-10-15 18:30 +0200
  [PATCH 2/2] bitops.h: add sign_extend64() Martin Kepplinger <martink@posteo.de> - 2015-10-15 18:30 +0200
  [PATCH 1/2] bitops.h: Improve sign_extend32()'s documentation Martin Kepplinger <martink@posteo.de> - 2015-10-15 18:30 +0200
    Re: [PATCH 1/2] bitops.h: Improve sign_extend32()'s documentation "George Spelvin" <linux@horizon.com> - 2015-10-15 20:10 +0200

csiph-web