Den 24-09-2013 08:00, Niels Baggesen skrev:
On Mon, Sep 23, 2013 at 10:58:13AM +0100, Mike Moreton wrote:
I thought this was meant to be the way of specifying a bit mask,
but it just comes out as "%b", which isn't a lot of use!
Am I doing something wrong?
No. It seems that we forgot the 'b' case when implementing the code
for DISPLAY-HINT :-(
or at least mis-implemented it ..
Could you try this patch and see if it fixes it?
/Niels
--
Niels Baggesen - @home - Ã…rhus - Denmark - n...@users.sourceforge.net
The purpose of computing is insight, not numbers --- R W Hamming
diff --git a/snmplib/mib.c b/snmplib/mib.c
index 46936c6..ec45d73 100644
--- a/snmplib/mib.c
+++ b/snmplib/mib.c
@@ -1207,7 +1207,7 @@ sprint_realloc_timeticks(u_char ** buf, size_t * buf_len, size_t * out_len,
* @param allow_realloc if not zero reallocate the buffer to fit the
* needed size.
* @param val The variable to encode.
- * @param decimaltype The enumeration ff this variable is enumerated. may be NULL.
+ * @param decimaltype 'd' or 'u' depending on integer type
* @param hint Contents of the DISPLAY-HINT clause of the MIB.
* See RFC 1903 Section 3.1 for details. may _NOT_ be NULL.
* @param units Contents of the UNITS clause of the MIB. may be NULL.
@@ -1242,7 +1242,18 @@ sprint_realloc_hinted_integer(u_char ** buf, size_t * buf_len,
fmt[2] = hint[0];
}
- sprintf(tmp, fmt, val);
+ if (hint[0] == 'b') {
+ unsigned long int bit = 0x80000000LU;
+ char *bp = tmp;
+ while (bit) {
+ *bp++ = val & bit ? '1' : '0';
+ bit >>= 1;
+ }
+ *bp = 0;
+ }
+ else
+ sprintf(tmp, fmt, val);
+
if (shift != 0) {
len = strlen(tmp);
if (shift <= len) {
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders